Search in sources :

Example 1 with Namespace

use of org.gitlab4j.api.models.Namespace in project choerodon-starters by open-hand.

the class NamespaceApi method findNamespaces.

/**
 * Get all namespaces that match a string in their name or path in the specified page range.
 * <p>
 * GET /namespaces?search=:query
 *
 * @param query   the search string
 * @param page    the page to get
 * @param perPage the number of Namespace instances per page
 * @return the Namespace List with the matching namespaces
 * @throws GitLabApiException if any exception occurs
 */
public List<Namespace> findNamespaces(String query, int page, int perPage) throws GitLabApiException {
    GitLabApiForm formData = new GitLabApiForm().withParam("search", query, true).withParam(PAGE_PARAM, page).withParam(PER_PAGE_PARAM, perPage);
    Response response = get(Response.Status.OK, formData.asMap(), "namespaces");
    return (response.readEntity(new GenericType<List<Namespace>>() {
    }));
}
Also used : Response(javax.ws.rs.core.Response) GenericType(javax.ws.rs.core.GenericType) Namespace(org.gitlab4j.api.models.Namespace)

Example 2 with Namespace

use of org.gitlab4j.api.models.Namespace in project catma by forTEXT.

the class GitlabManagerRestricted method createRepository.

@Override
public CreateRepositoryResponse createRepository(String name, String path, String groupPath) throws IOException {
    GroupApi groupApi = restrictedGitLabApi.getGroupApi();
    ProjectApi projectApi = restrictedGitLabApi.getProjectApi();
    try {
        Group group = groupApi.getGroup(groupPath);
        Namespace namespace = new Namespace();
        namespace.setId(group.getId());
        Project project = new Project();
        project.setName(name);
        project.setNamespace(namespace);
        if (StringUtils.isNotEmpty(path)) {
            project.setPath(path);
        }
        project = projectApi.createProject(project);
        return new CreateRepositoryResponse(groupPath, project.getId(), GitlabUtils.rewriteGitLabServerUrl(project.getHttpUrlToRepo()));
    } catch (GitLabApiException e) {
        throw new IOException("Failed to create remote Git repository", e);
    }
}
Also used : Group(org.gitlab4j.api.models.Group) Project(org.gitlab4j.api.models.Project) GroupApi(org.gitlab4j.api.GroupApi) ProjectApi(org.gitlab4j.api.ProjectApi) CreateRepositoryResponse(de.catma.repository.git.CreateRepositoryResponse) GitLabApiException(org.gitlab4j.api.GitLabApiException) IOException(java.io.IOException) Namespace(org.gitlab4j.api.models.Namespace)

Example 3 with Namespace

use of org.gitlab4j.api.models.Namespace in project choerodon-starters by open-hand.

the class NamespaceApi method findNamespaces.

/**
 * Get all namespaces that match a string in their name or path.
 * <p>
 * GET /namespaces?search=:query
 *
 * @param query the search string
 * @return the Namespace List with the matching namespaces
 * @throws GitLabApiException if any exception occurs
 */
public List<Namespace> findNamespaces(String query) throws GitLabApiException {
    GitLabApiForm formData = new GitLabApiForm().withParam("search", query, true).withParam(PER_PAGE_PARAM, getDefaultPerPage());
    Response response = get(Response.Status.OK, formData.asMap(), "namespaces");
    return (response.readEntity(new GenericType<List<Namespace>>() {
    }));
}
Also used : Response(javax.ws.rs.core.Response) GenericType(javax.ws.rs.core.GenericType) Namespace(org.gitlab4j.api.models.Namespace)

Aggregations

Namespace (org.gitlab4j.api.models.Namespace)3 GenericType (javax.ws.rs.core.GenericType)2 Response (javax.ws.rs.core.Response)2 CreateRepositoryResponse (de.catma.repository.git.CreateRepositoryResponse)1 IOException (java.io.IOException)1 GitLabApiException (org.gitlab4j.api.GitLabApiException)1 GroupApi (org.gitlab4j.api.GroupApi)1 ProjectApi (org.gitlab4j.api.ProjectApi)1 Group (org.gitlab4j.api.models.Group)1 Project (org.gitlab4j.api.models.Project)1