Commit 4769949a authored by Mustafa YILDIRIM's avatar Mustafa YILDIRIM Committed by Tim Olshansky

Add jira service (#220)

parent 90c9f2ae
......@@ -2771,6 +2771,65 @@ public class GitlabAPI {
return retrieve().method("PUT").to(tailUrl, Boolean.class);
}
/**
* Get JIRA service settings for a project.
* https://docs.gitlab.com/ce/api/services.html#get-jira-service-settings
*
* @param projectId The ID of the project containing the variable.
* @return
* @throws IOException
*/
public GitlabServiceJira getJiraService(Integer projectId) throws IOException{
String tailUrl = GitlabProject.URL+ "/" + projectId + GitlabServiceJira.URL;
return retrieve().to(tailUrl, GitlabServiceJira.class);
}
/**
* Remove all previously JIRA settings from a project.
* https://docs.gitlab.com/ce/api/services.html#delete-jira-service
*
* @param projectId The ID of the project containing the variable.
* @return
* @throws IOException
*/
public boolean deleteJiraService(Integer projectId) throws IOException{
String tailUrl = GitlabProject.URL+ "/" + projectId + GitlabServiceJira.URL;
return retrieve().method("DELETE").to(tailUrl, Boolean.class);
}
/**
* Set JIRA service for a project.
* https://docs.gitlab.com/ce/api/services.html#create-edit-jira-service
*
* @param projectId The ID of the project containing the variable.
* @param jiraPropties
* @return
* @throws IOException
*/
public boolean createOrEditJiraService(Integer projectId, GitlabJiraProperties jiraPropties) throws IOException{
Query query = new Query()
.appendIf("url", jiraPropties.getUrl())
.appendIf("project_key", jiraPropties.getProjectKey());
if(!jiraPropties.getUsername().isEmpty()){
query.appendIf("username", jiraPropties.getUsername());
}
if(!jiraPropties.getPassword().isEmpty()){
query.appendIf("password", jiraPropties.getPassword());
}
if(jiraPropties.getIssueTransitionId() != null){
query.appendIf("jira_issue_transition_id", jiraPropties.getIssueTransitionId());
}
String tailUrl = GitlabProject.URL+ "/" + projectId + GitlabServiceJira.URL+ query.toString();
return retrieve().method("PUT").to(tailUrl, Boolean.class);
}
/**
*
* Get a list of projects accessible by the authenticated user by search.
......
package org.gitlab.api.models;
import com.fasterxml.jackson.annotation.JsonProperty;
public class GitlabJiraProperties {
private String url;
@JsonProperty("project_key")
private String projectKey;
private String username;
private String password;
@JsonProperty("jira_issue_transition_id")
private Integer issueTransitionId;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getProjectKey() {
return projectKey;
}
public void setProjectKey(String projectKey) {
this.projectKey = projectKey;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Integer getIssueTransitionId() {
return issueTransitionId;
}
public void setIssueTransitionId(Integer issueTransitionId) {
this.issueTransitionId = issueTransitionId;
}
}
package org.gitlab.api.models;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonProperty;
public class GitlabServiceJira {
public static final String URL = "/services/jira/";
private Integer id;
private String title;
@JsonProperty("created_at")
private Date createdAt;
@JsonProperty("updated_at")
private Date updatedAt;
private boolean active;
private boolean push_events;
private boolean issues_events;
private boolean merge_requests_events;
private boolean tag_push_events;
private boolean note_events;
private boolean build_events;
private GitlabJiraProperties properties;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
public boolean isPushEvents() {
return push_events;
}
public void setPushEvents(boolean push_events) {
this.push_events = push_events;
}
public boolean isIssuesEvents() {
return issues_events;
}
public void setIssuesEvents(boolean issues_events) {
this.issues_events = issues_events;
}
public boolean isMergeRequestsEvents() {
return merge_requests_events;
}
public void setMergeRequestsEvents(boolean merge_requests_events) {
this.merge_requests_events = merge_requests_events;
}
public boolean isTagPushEvents() {
return tag_push_events;
}
public void setTagPushEvents(boolean tag_push_events) {
this.tag_push_events = tag_push_events;
}
public boolean isNoteEvents() {
return note_events;
}
public void setNoteEvents(boolean note_events) {
this.note_events = note_events;
}
public boolean isBuildEvents() {
return build_events;
}
public void setBuildEvents(boolean build_events) {
this.build_events = build_events;
}
public GitlabJiraProperties getProperties() {
return properties;
}
public void setProperties(GitlabJiraProperties properties) {
this.properties = properties;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment