org.gitlab.api.http.Query类的使用及代码示例

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

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

Query介绍

[英]Models the Query aspect of a URL
[中]对URL的查询方面进行建模

代码示例

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

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

代码示例来源: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: timols/java-gitlab-api

/**
 * Generates query representing this request's properties.
 * @return {@link Query}
 * @throws UnsupportedEncodingException 
 */
public Query toQuery() throws UnsupportedEncodingException{
 return new Query()
   .append("name", name)
   .append("path", path)
   .appendIf("ldap_cn", ldapCn)
   .appendIf("description", description)
   .appendIf("membershipLock", membershipLock)
   .appendIf("share_with_group_lock", shareWithGroupLock)
   .appendIf("visibility", visibility != null ? visibility.toString() : null)
   .appendIf("lfs_enabled", lfsEnabled)
   .appendIf("request_access_enabled", requestAccessEnabled)
   .appendIf("parent_id", parentId);
}

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

/**
 * Add a project member.
 *
 * @param projectId   the project id
 * @param userId      the user id
 * @param accessLevel the GitlabAccessLevel
 * @return the GitlabProjectMember
 * @throws IOException on gitlab api call error
 */
public GitlabProjectMember addProjectMember(Integer projectId, Integer userId, GitlabAccessLevel accessLevel) throws IOException {
  Query query = new Query()
      .appendIf("id", projectId)
      .appendIf("user_id", userId)
      .appendIf("access_level", accessLevel);
  String tailUrl = GitlabProject.URL + "/" + projectId + GitlabProjectMember.URL + query.toString();
  return dispatch().to(tailUrl, GitlabProjectMember.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

/**
 * Share a project with a group.
 *
 * @param accessLevel The permissions level to grant the group.
 * @param group       The group to share with.
 * @param project     The project to be shared.
 * @param expiration  Share expiration date in ISO 8601 format: 2016-09-26 or {@code null}.
 * @throws IOException on gitlab api call error
 */
public void shareProjectWithGroup(GitlabAccessLevel accessLevel, String expiration, GitlabGroup group, GitlabProject project) throws IOException {
  Query query = new Query()
      .append("group_id", group.getId().toString())
      .append("group_access", String.valueOf(accessLevel.accessValue))
      .appendIf("expires_at", expiration);
  String tailUrl = GitlabProject.URL + "/" + project.getId() + "/share" + query.toString();
  dispatch().to(tailUrl, 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

/**
 * Get an archive of the repository
 *
 * @param project The Project
 * @param path    The path inside the repository. Used to get content of subdirectories (optional)
 * @param ref     The name of a repository branch or tag or if not given the default branch (optional)
 * @throws IOException on gitlab api call error
 */
public List<GitlabRepositoryTree> getRepositoryTree(GitlabProject project, String path, String ref, boolean recursive) throws IOException {
  Query query = new Pagination().withPerPage(Pagination.MAX_ITEMS_PER_PAGE).asQuery()
      .appendIf("path", path)
      .appendIf("ref", ref)
      .appendIf("recursive", recursive);
  String tailUrl = GitlabProject.URL + "/" + project.getId() + "/repository" + GitlabRepositoryTree.URL + query.toString();
  return retrieve().getAll(tailUrl, GitlabRepositoryTree[].class);
}

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

@Test
public void emptyPagination() {
  Pagination pagination = new Pagination();
  final Query expectedQuery = new Query();
  assertEquals(expectedQuery.toString(), pagination.toString());
  assertEquals(expectedQuery.toString(), pagination.asQuery().toString());
}

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

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

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

@Override
  public String toString() {
    return paginationQuery.toString();
  }
}

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

/**
 * @param namespace The namespace of the fork
 * @param projectId ProjectId of the project forked
 * @return The new Gitlab Project
 * @throws IOException on gitlab api call error
 */
public GitlabProject createFork(String namespace, Integer projectId) throws IOException {
  Query query = new Query()
      .appendIf("namespace", namespace);
  String tailUrl = GitlabProject.URL + "/" + projectId + "/fork" + query.toString();
  return dispatch().to(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

/**
 * Share a project with a group.
 *
 * @param accessLevel The permissions level to grant the group.
 * @param group       The group to share with.
 * @param project     The project to be shared.
 * @param expiration  Share expiration date in ISO 8601 format: 2016-09-26 or {@code null}.
 * @throws IOException on gitlab api call error
 */
public void shareProjectWithGroup(GitlabAccessLevel accessLevel, String expiration, GitlabGroup group, GitlabProject project) throws IOException {
  Query query = new Query()
      .append("group_id", group.getId().toString())
      .append("group_access", String.valueOf(accessLevel.accessValue))
      .appendIf("expires_at", expiration);
  String tailUrl = GitlabProject.URL + "/" + project.getId() + "/share" + query.toString();
  dispatch().to(tailUrl, 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

/**
 * Get an archive of the repository
 *
 * @param project The Project
 * @param path    The path inside the repository. Used to get content of subdirectories (optional)
 * @param ref     The name of a repository branch or tag or if not given the default branch (optional)
 * @throws IOException on gitlab api call error
 */
public List<GitlabRepositoryTree> getRepositoryTree(GitlabProject project, String path, String ref, boolean recursive) throws IOException {
  Query query = new Pagination().withPerPage(Pagination.MAX_ITEMS_PER_PAGE).asQuery()
      .appendIf("path", path)
      .appendIf("ref", ref)
      .appendIf("recursive", recursive);
  String tailUrl = GitlabProject.URL + "/" + project.getId() + "/repository" + GitlabRepositoryTree.URL + query.toString();
  return retrieve().getAll(tailUrl, GitlabRepositoryTree[].class);
}

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

/**
 * Generates query representing this request's properties.
 * @return {@link Query}
 * @throws UnsupportedEncodingException 
 */
public Query toQuery() throws UnsupportedEncodingException{
 return new Query()
   .append("name", name)
   .append("path", path)
   .appendIf("ldap_cn", ldapCn)
   .appendIf("description", description)
   .appendIf("membershipLock", membershipLock)
   .appendIf("share_with_group_lock", shareWithGroupLock)
   .appendIf("visibility", visibility != null ? visibility.toString() : null)
   .appendIf("lfs_enabled", lfsEnabled)
   .appendIf("request_access_enabled", requestAccessEnabled)
   .appendIf("parent_id", parentId);
}

代码示例来源: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

/**
 * Create a new user. This may succeed only if the requester is an administrator.
 *
 * @param request An object that represents the parameters for the request.
 * @return {@link GitlabUser}
 * @throws IOException on gitlab api call error
 */
public GitlabUser createUser(CreateUserRequest request) throws IOException {
  String tailUrl = GitlabUser.USERS_URL + request.toQuery().toString();
  return dispatch().to(tailUrl, GitlabUser.class);
}

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

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

相关文章