Java Code Examples for org.gitlab.api.http.Query#append()

The following examples show how to use org.gitlab.api.http.Query#append() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GitlabAPI.java    From java-gitlab-api with Apache License 2.0 6 votes vote down vote up
public List<GitlabCommit> getCommits(Serializable projectId, Pagination pagination,
                                     String branchOrTag, String path) throws IOException {
    final Query query = new Query();
    if (branchOrTag != null) {
        query.append("ref_name", branchOrTag);
    }
    if (path != null) {
        query.append("path", path);
    }
    if (pagination != null) {
        query.mergeWith(pagination.asQuery());
    }

    String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) +
            "/repository" + GitlabCommit.URL + query;
    final GitlabCommit[] commits = retrieve().to(tailUrl, GitlabCommit[].class);
    return Arrays.asList(commits);
}
 
Example 2
Source File: GitlabAPI.java    From java-gitlab-api with Apache License 2.0 6 votes vote down vote up
public GitlabProjectHook editProjectHook(GitlabProject project, String hookId, String url,
    boolean pushEvents, boolean issuesEvents, boolean mergeRequestEvents, boolean noteEvents,
    boolean tagPushEvents, boolean sslVerification, boolean jobEvents, boolean pipelineEvents,
    boolean wikiPageEvents, String token) throws IOException {
    Query query = new Query();
    query.append("url", url);
    query.append("push_events", String.valueOf(pushEvents));
    query.append("issues_events", String.valueOf(issuesEvents));
    query.append("merge_request_events", String.valueOf(mergeRequestEvents));
    query.append("note_events", String.valueOf(noteEvents));
    query.append("tag_push_events", String.valueOf(tagPushEvents));
    query.append("enable_ssl_verification", String.valueOf(sslVerification));
    query.append("job_events", String.valueOf(jobEvents));
    query.append("pipeline_events", String.valueOf(pipelineEvents));
    query.append("wiki_page_events", String.valueOf(wikiPageEvents));
    query.append("token", token);
    String tailUrl = GitlabProject.URL + "/" + project.getId() + GitlabProjectHook.URL + "/" + hookId + query.toString();
    return retrieve().method(PUT).to(tailUrl, GitlabProjectHook.class);
}
 
Example 3
Source File: GitLabAPI.java    From gitlab-branch-source-plugin with GNU General Public License v2.0 5 votes vote down vote up
public List<GitlabRepositoryTree> getTree(int id, String ref, String path) throws GitLabAPIException {
    try {
        Query query = new Query()
                .appendIf("path", path)
                .appendIf("ref", ref);

        query.append("per_page","10000");
        String tailUrl = GitlabProject.URL + "/" + id + "/repository" + GitlabRepositoryTree.URL + query.toString();
        LOGGER.fine("tailurl: " + tailUrl);
        GitlabRepositoryTree[] tree = delegate.retrieve().to(tailUrl, GitlabRepositoryTree[].class);
        return Arrays.asList(tree);
    } catch (Exception e) {
        throw new GitLabAPIException(e);
    }
}
 
Example 4
Source File: GitlabAPI.java    From java-gitlab-api with Apache License 2.0 5 votes vote down vote up
public List<GitlabCommit> getAllCommits(Serializable projectId, Pagination pagination,
                                        String branchOrTag) throws IOException {
    final Query query = new Query();
    if (branchOrTag != null) {
        query.append("ref_name", branchOrTag);
    }

    if (pagination != null) {
        query.mergeWith(pagination.asQuery());
    }

    String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) +
            "/repository" + GitlabCommit.URL + query;
    return retrieve().getAll(tailUrl, GitlabCommit[].class);
}
 
Example 5
Source File: GitlabAPI.java    From java-gitlab-api with Apache License 2.0 5 votes vote down vote up
/**
 * Deletes an existing label.
 *
 * @param projectId The ID of the project containing the label.
 * @param name      The name of the label to delete.
 * @throws IOException on gitlab api call error
 */
public void deleteLabel(Serializable projectId, String name)
        throws IOException {
    Query query = new Query();
    query.append("name", name);
    String tailUrl = GitlabProject.URL + "/" +
            sanitizeProjectId(projectId) +
            GitlabLabel.URL +
            query.toString();
    retrieve().method(DELETE).to(tailUrl, Void.class);
}
 
Example 6
Source File: GitlabAPI.java    From java-gitlab-api with Apache License 2.0 4 votes vote down vote up
public List<GitlabMergeRequest> getMergeRequestsWithStatus(Serializable projectId, String state, Pagination pagination) throws IOException {
    Query query = pagination.asQuery();
    query.append("state", state);
    String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabMergeRequest.URL + query;
    return retrieve().getAll(tailUrl, GitlabMergeRequest[].class);
}
 
Example 7
Source File: GitlabAPI.java    From java-gitlab-api with Apache License 2.0 4 votes vote down vote up
public List<GitlabMergeRequest> getMergeRequestsWithStatus(GitlabProject project, String state, Pagination pagination) throws IOException {
    Query query = pagination.asQuery();
    query.append("state", state);
    String tailUrl = GitlabProject.URL + "/" + project.getId() + GitlabMergeRequest.URL + query;
    return retrieve().getAll(tailUrl, GitlabMergeRequest[].class);
}