org.gitlab.api.http.Query.append()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(195)

本文整理了Java中org.gitlab.api.http.Query.append方法的一些代码示例,展示了Query.append的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.append方法的具体详情如下:
包路径:org.gitlab.api.http.Query
类名称:Query
方法名:append

Query.append介绍

[英]Appends a parameter to the query
[中]将参数附加到查询

代码示例

代码示例来源:origin: timols/java-gitlab-api

public void setPage(int page) {
  try {
    paginationQuery.append(PARAM_PAGE, String.valueOf(page));
  } catch (UnsupportedEncodingException ignored) {
  }
}

代码示例来源:origin: org.gitlab/java-gitlab-api

public void setPerPage(int perPage) {
  if (perPage > MAX_ITEMS_PER_PAGE) {
    throw new IllegalArgumentException("Max value for perPage is " + MAX_ITEMS_PER_PAGE);
  }
  try {
    paginationQuery.append(PARAM_PER_PAGE, String.valueOf(perPage));
  } catch (UnsupportedEncodingException ignored) {
  }
}

代码示例来源:origin: timols/java-gitlab-api

private GitlabSSHKey createDeployKey(Integer targetProjectId, String title, String key, boolean canPush) throws IOException {
  Query query = new Query()
      .append("title", title)
      .append("key", key)
      .append("can_push", Boolean.toString(canPush));
  String tailUrl = GitlabProject.URL + "/" + targetProjectId + GitlabSSHKey.DEPLOY_KEYS_URL + query.toString();
  return dispatch().to(tailUrl, GitlabSSHKey.class);
}

代码示例来源:origin: org.gitlab/java-gitlab-api

private GitlabSSHKey createDeployKey(Integer targetProjectId, String title, String key, boolean canPush) throws IOException {
  Query query = new Query()
      .append("title", title)
      .append("key", key)
      .append("can_push", Boolean.toString(canPush));
  String tailUrl = GitlabProject.URL + "/" + targetProjectId + GitlabSSHKey.DEPLOY_KEYS_URL + query.toString();
  return dispatch().to(tailUrl, GitlabSSHKey.class);
}

代码示例来源:origin: timols/java-gitlab-api

public void protectBranchWithDeveloperOptions(GitlabProject project, String branchName, boolean developers_can_push, boolean developers_can_merge) throws IOException {
  String tailUrl = GitlabProject.URL + "/" + project.getId() + GitlabBranch.URL + '/' + sanitizePath(branchName) + "/protect";
  final Query query = new Query()
      .append("developers_can_push", Boolean.toString(developers_can_push))
      .append("developers_can_merge", Boolean.toString(developers_can_merge));
  retrieve().method(PUT).to(tailUrl + query.toString(), Void.class);
}

代码示例来源:origin: org.gitlab/java-gitlab-api

public void protectBranchWithDeveloperOptions(GitlabProject project, String branchName, boolean developers_can_push, boolean developers_can_merge) throws IOException {
  String tailUrl = GitlabProject.URL + "/" + project.getId() + GitlabBranch.URL + '/' + sanitizePath(branchName) + "/protect";
  final Query query = new Query()
      .append("developers_can_push", Boolean.toString(developers_can_push))
      .append("developers_can_merge", Boolean.toString(developers_can_merge));
  retrieve().method(PUT).to(tailUrl + query.toString(), Void.class);
}

代码示例来源:origin: timols/java-gitlab-api

public void protectBranchWithDeveloperOptions(GitlabProject project, String branchName, boolean developers_can_push, boolean developers_can_merge) throws IOException {
  String tailUrl = GitlabProject.URL + "/" + project.getId() + GitlabBranch.URL + '/' + sanitizePath(branchName) + "/protect";
  final Query query = new Query()
      .append("developers_can_push", Boolean.toString(developers_can_push))
      .append("developers_can_merge", Boolean.toString(developers_can_merge));
  retrieve().method(PUT).to(tailUrl + query.toString(), Void.class);
}

代码示例来源:origin: timols/java-gitlab-api

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);
}

代码示例来源:origin: timols/java-gitlab-api

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);
}

代码示例来源:origin: timols/java-gitlab-api

@Test
public void mixedStyle_append() throws UnsupportedEncodingException {
  Query query = new Query()
      .append("p1", "v1");
  query.append("p2", "v2");
  query = query.append("p3", "v3");
  assertEquals("?p1=v1&p2=v2&p3=v3", query.toString());
}

代码示例来源:origin: timols/java-gitlab-api

/**
 * Transfer a project to the given namespace
 *
 * @param namespaceId Namespace ID
 * @param projectId   Project ID
 * @throws IOException on gitlab api call error
 */
public void transfer(Integer namespaceId, Integer projectId) throws IOException {
  Query query = new Query().append("namespace", String.valueOf(namespaceId));
  String tailUrl = GitlabProject.URL + "/" + projectId + "/transfer" + query.toString();
  retrieve().method(PUT).to(tailUrl, Void.class);
}

代码示例来源:origin: timols/java-gitlab-api

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);
}

代码示例来源:origin: timols/java-gitlab-api

@Test
  public void merge() throws UnsupportedEncodingException{
    Query sourceQuery= new Query()
        .append("p1", "v1")
        .append("p2", "v2");

    Query targetQuery = new Query()
        .append("p3", "v3")
        .append("p2", "v22");

    boolean mergeResult = targetQuery.mergeWith(sourceQuery);

    assertTrue(mergeResult);
    assertEquals("?p3=v3&p2=v22&p1=v1&p2=v2", targetQuery.toString());
  }
}

代码示例来源:origin: timols/java-gitlab-api

@Test
public void append_encodes_values() throws UnsupportedEncodingException {
  Query query = new Query()
      .append("p1", "v 1")
      .append("p2", "v 2");
  assertEquals("?p1=v+1&p2=v+2", query.toString());
}

代码示例来源:origin: timols/java-gitlab-api

public GitlabRepositoryFile getRepositoryFile(GitlabProject project, String path, String ref) throws IOException {
  Query query = new Query()
      .append("ref", ref);
  String tailUrl = GitlabProject.URL + "/" + project.getId() + "/repository/files/" + sanitizePath(path) + query.toString();
  return retrieve().to(tailUrl, GitlabRepositoryFile.class);
}

代码示例来源:origin: timols/java-gitlab-api

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);
}

代码示例来源:origin: timols/java-gitlab-api

/**
 * 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);
}

代码示例来源:origin: timols/java-gitlab-api

/**
 * 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);
}

代码示例来源:origin: timols/java-gitlab-api

/**
 * 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);
}

代码示例来源:origin: timols/java-gitlab-api

/**
 * 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);
}

相关文章