Commit 2b55521f authored by Tim Olshansky's avatar Tim Olshansky Committed by GitHub

Merge pull request #166 from mfriedenhagen/owned-projects-and-project-triggers

Owned projects and project triggers
parents fd82dab3 e71e9866
......@@ -583,6 +583,18 @@ public class GitlabAPI {
return retrieve().getAll(tailUrl, GitlabProject[].class);
}
/**
*
* Get a list of projects owned by the authenticated user.
*
* @return A list of gitlab projects
* @throws IOException
*/
public List<GitlabProject> getOwnedProjects() throws IOException {
String tailUrl = GitlabProject.URL + "/owned";
return retrieve().getAll(tailUrl, GitlabProject[].class);
}
/**
*
* Get a list of projects accessible by the authenticated user.
......@@ -2374,4 +2386,22 @@ public class GitlabAPI {
}
return requestor.to(tailUrl, GitlabBuildVariable.class);
}
/**
* Returns the list of build triggers for a project.
*
* @param project the project
* @return list of build triggers
* @throws IllegalStateException if builds are not enabled for the project
* @throws IOException
*/
public List<GitlabTrigger> getBuildTriggers(GitlabProject project) throws IOException {
if (!project.isBuildsEnabled()) {
// if the project has not allowed builds, you will only get a 403 forbidden message which is
// not helpful.
throw new IllegalStateException("Builds are not enabled for " + project.getNameWithNamespace() );
} else {
return retrieve().getAll(GitlabProject.URL + "/" + project.getId() + GitlabTrigger.URL, GitlabTrigger[].class);
}
}
}
package org.gitlab.api.models;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Date;
/**
* [
* {
* "token": "7dfb8f45432193abcd54123456090f",
* "created_at": "2016-07-08T12:33:25.151Z",
* "updated_at": "2016-07-08T12:33:25.151Z",
* "deleted_at": null,
* "last_used": "2016-09-04T23:00:01.681Z"
* }
* ]
*/
public class GitlabTrigger {
public static final String URL = "/triggers";
private String token;
@JsonProperty("created_at")
private Date createdAt;
@JsonProperty("updated_at")
private Date updatedAt;
@JsonProperty("deleted_at")
private Date deletedAt;
@JsonProperty("last_used")
private Date lastUsed;
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
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 Date getDeletedAt() {
return deletedAt;
}
public void setDeletedAt(Date deletedAt) {
this.deletedAt = deletedAt;
}
public Date getLastUsed() {
return lastUsed;
}
public void setLastUsed(Date lastUsed) {
this.lastUsed = lastUsed;
}
}
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