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

The following examples show how to use org.gitlab.api.http.Query#mergeWith() . 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 5 votes vote down vote up
public List<GitlabGroup> getGroupsViaSudo(String username, Pagination pagination) throws IOException {
    String tailUrl = GitlabGroup.URL;

    Query query = new Query()
            .appendIf(PARAM_SUDO, username);

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

    return retrieve().getAll(tailUrl + query.toString(), GitlabGroup[].class);
}
 
Example 3
Source File: GitlabAPI.java    From java-gitlab-api with Apache License 2.0 5 votes vote down vote up
/**
 * Get a list of projects owned by the authenticated user.
 *
 * @return A list of gitlab projects
 * @throws IOException on gitlab api call error
 */
public List<GitlabProject> getOwnedProjects() throws IOException {
    Query query = new Query().append("owned", "true");
    query.mergeWith(new Pagination().withPerPage(Pagination.MAX_ITEMS_PER_PAGE).asQuery());
    String tailUrl = GitlabProject.URL + query.toString();
    return retrieve().getAll(tailUrl, GitlabProject[].class);
}
 
Example 4
Source File: GitlabAPI.java    From java-gitlab-api with Apache License 2.0 5 votes vote down vote up
/**
 * Get a list of projects that the authenticated user is a member of.
 *
 * @return A list of gitlab projects
 * @throws IOException on gitlab api call error
 */
public List<GitlabProject> getMembershipProjects() throws IOException {
    Query query = new Query().append("membership", "true");
    query.mergeWith(new Pagination().withPerPage(Pagination.MAX_ITEMS_PER_PAGE).asQuery());
    String tailUrl = GitlabProject.URL + query.toString();
    return retrieve().getAll(tailUrl, GitlabProject[].class);
}
 
Example 5
Source File: GitlabAPI.java    From java-gitlab-api with Apache License 2.0 5 votes vote down vote up
/**
 * Get a list of projects starred by the authenticated user.
 *
 * @return A list of gitlab projects
 * @throws IOException on gitlab api call error
 */
public List<GitlabProject> getStarredProjects() throws IOException {
    Query query = new Query().append("starred", "true");
    query.mergeWith(new Pagination().withPerPage(Pagination.MAX_ITEMS_PER_PAGE).asQuery());
    String tailUrl = GitlabProject.URL + query.toString();
    return retrieve().getAll(tailUrl, GitlabProject[].class);
}
 
Example 6
Source File: GitlabAPI.java    From java-gitlab-api with Apache License 2.0 5 votes vote down vote up
/**
 * Get a list of projects accessible by the authenticated user.
 *
 * @return A list of gitlab projects
 * @throws IOException on gitlab api call error
 */
public List<GitlabProject> getProjectsViaSudo(GitlabUser user) throws IOException {
    Query query = new Query()
            .appendIf(PARAM_SUDO, user.getId());
    query.mergeWith(new Pagination().withPerPage(Pagination.MAX_ITEMS_PER_PAGE).asQuery());
    String tailUrl = GitlabProject.URL + query.toString();
    return retrieve().getAll(tailUrl, GitlabProject[].class);
}
 
Example 7
Source File: GitlabAPI.java    From java-gitlab-api with Apache License 2.0 5 votes vote down vote up
/**
 * Get a list of projects of with Pagination.
 *
 * @param user       Gitlab User to invoke sudo with
 * @param pagination
 * @return A list of gitlab projects
 * @throws IOException Gitlab API call error
 */
public List<GitlabProject> getProjectsViaSudoWithPagination(GitlabUser user, Pagination pagination) throws IOException {
    StringBuilder tailUrl = new StringBuilder(GitlabProject.URL);

    Query query = new Query()
            .appendIf(PARAM_SUDO, user.getId());

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

    tailUrl.append(query.toString());
    return Arrays.asList(retrieve().method(GET).to(tailUrl.toString(), GitlabProject[].class));
}
 
Example 8
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 9
Source File: GitlabAPI.java    From java-gitlab-api with Apache License 2.0 5 votes vote down vote up
public GitlabCommitComparison compareCommits(Serializable projectId, String commitHash1, String commitHash2, Pagination pagination) throws IOException {
    String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabCommitComparison.URL;
    Query query = new Query()
            .append("from", commitHash1)
            .append("to", commitHash2);
    query.mergeWith(pagination.asQuery());
    return retrieve().to(tailUrl + query, GitlabCommitComparison.class);
}
 
Example 10
Source File: GitlabAPI.java    From java-gitlab-api with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a list of runners with perPage elements on the page number specified.
 *
 * @param scope      Can be null. Defines type of Runner to retrieve.
 * @param pagination Can be null. Pagination to query by.
 * @return List of GitlabRunners
 * @throws IOException on Gitlab API call error
 */
public List<GitlabRunner> getRunnersWithPagination(GitlabRunner.RunnerScope scope, Pagination pagination) throws IOException {
    StringBuilder tailUrl = new StringBuilder(GitlabRunner.URL).append("/all");
    Query query = new Query()
            .appendIf("scope", scope.getScope());

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

    tailUrl.append(query.toString());
    return Arrays.asList(retrieve().method(GET).to(tailUrl.toString(), GitlabRunner[].class));
}
 
Example 11
Source File: GitlabAPI.java    From java-gitlab-api with Apache License 2.0 5 votes vote down vote up
/**
 * Get events for a project.
 *
 * @param action If not null, include only events of a particular action type
 * @param targetType If not null, include only events of a particular target type
 * @param before If not null, include only events created before a particular date.
 * @param after If not null, include only events created before a
 * particular date.
 * @param sort If null, uses the server's default, which is "desc"
 */
public List<GitlabEvent> getProjectEvents(Serializable projectId,
                                          GitlabEvent.ActionType action,
                                          GitlabEvent.TargetType targetType,
                                          GitlabDate before,
                                          GitlabDate after,
                                          SortOrder sort,
                                          Pagination pagination)
    throws IOException {

    final Query query = new Query();
    query.appendIf("action", action);
    query.appendIf("target_type", targetType);
    query.appendIf("before", before);
    query.appendIf("after", after);
    query.appendIf("sort", sort);

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

    StringBuilder tailUrl = new StringBuilder(GitlabProject.URL)
        .append("/")
        .append(sanitizeProjectId(projectId))
        .append(GitlabEvent.URL)
        .append(query.toString());

    return Arrays.asList(retrieve().method(GET).to(tailUrl.toString(), GitlabEvent[].class));
}