Search in sources :

Example 1 with GroupApi

use of org.gitlab4j.api.GroupApi in project OpenUnison by TremoloSecurity.

the class GitlabUserProvider method init.

@Override
public void init(Map<String, Attribute> cfg, ConfigManager cfgMgr, String name) throws ProvisioningException {
    this.token = cfg.get("token").getValues().get(0);
    this.url = cfg.get("url").getValues().get(0);
    this.name = name;
    this.gitLabApi = new GitLabApi(this.url, this.token);
    this.userApi = new UserApi(this.gitLabApi);
    this.groupApi = new GroupApi(this.gitLabApi);
    this.cfgMgr = cfgMgr;
}
Also used : GitLabApi(org.gitlab4j.api.GitLabApi) GroupApi(org.gitlab4j.api.GroupApi) UserApi(org.gitlab4j.api.UserApi)

Example 2 with GroupApi

use of org.gitlab4j.api.GroupApi in project catma by forTEXT.

the class GitlabManagerRestricted method deleteGroup.

@Override
public void deleteGroup(String path) throws IOException {
    GroupApi groupApi = restrictedGitLabApi.getGroupApi();
    try {
        // TODO: remove, deleteGroup can work with the path
        Group group = groupApi.getGroup(path);
        groupApi.deleteGroup(group);
    } catch (GitLabApiException e) {
        throw new IOException("Failed to delete remote group", e);
    }
}
Also used : Group(org.gitlab4j.api.models.Group) GroupApi(org.gitlab4j.api.GroupApi) GitLabApiException(org.gitlab4j.api.GitLabApiException) IOException(java.io.IOException)

Example 3 with GroupApi

use of org.gitlab4j.api.GroupApi in project catma by forTEXT.

the class GitlabManagerRestricted method leaveGroup.

@Override
public void leaveGroup(String path) throws IOException {
    GroupApi groupApi = restrictedGitLabApi.getGroupApi();
    try {
        Group group = groupApi.getGroup(path);
        Member member = groupApi.getMember(group.getId(), user.getUserId());
        if (member != null && member.getAccessLevel().value >= AccessLevel.GUEST.value && member.getAccessLevel().value < AccessLevel.OWNER.value) {
            groupApi.removeMember(group.getId(), user.getUserId());
        }
    } catch (GitLabApiException ge) {
        throw new IOException("Couldn't leave group", ge);
    }
}
Also used : Group(org.gitlab4j.api.models.Group) GroupApi(org.gitlab4j.api.GroupApi) GitLabApiException(org.gitlab4j.api.GitLabApiException) IOException(java.io.IOException) GitMember(de.catma.repository.git.GitMember) Member(org.gitlab4j.api.models.Member)

Example 4 with GroupApi

use of org.gitlab4j.api.GroupApi in project catma by forTEXT.

the class GitlabManagerRestricted method updateGroup.

@Override
public void updateGroup(String name, String path, String description) throws IOException {
    try {
        GroupApi groupApi = restrictedGitLabApi.getGroupApi();
        groupApi.updateGroup(path, name, path, description, null, null, null, null);
    } catch (GitLabApiException e) {
        throw new IOException("Failed to update name/description for group", e);
    }
}
Also used : GroupApi(org.gitlab4j.api.GroupApi) GitLabApiException(org.gitlab4j.api.GitLabApiException) IOException(java.io.IOException)

Example 5 with GroupApi

use of org.gitlab4j.api.GroupApi in project catma by forTEXT.

the class GitLabServerManagerTest method tearDown.

@AfterEach
public void tearDown() throws Exception {
    GitLabApi adminGitLabApi = gitlabManagerPrivileged.getGitLabApi();
    GroupApi groupApi = adminGitLabApi.getGroupApi();
    ProjectApi projectApi = adminGitLabApi.getProjectApi();
    UserApi userApi = adminGitLabApi.getUserApi();
    if (groupsToDeleteOnTearDown.size() > 0) {
        for (String groupPath : groupsToDeleteOnTearDown) {
            gitlabManagerRestricted.deleteGroup(groupPath);
            await().until(() -> groupApi.getGroups().isEmpty());
        }
    }
    if (repositoriesToDeleteOnTearDown.size() > 0) {
        for (Integer repositoryId : repositoriesToDeleteOnTearDown) {
            gitlabManagerRestricted.deleteRepository(repositoryId);
            await().until(() -> projectApi.getProjects().isEmpty());
        }
    }
    if (usersToDeleteOnTearDown.size() > 0) {
        for (Integer userId : usersToDeleteOnTearDown) {
            userApi.deleteUser(userId);
            GitLabServerManagerTest.awaitUserDeleted(userApi, userId);
        }
    }
    // delete the GitLab user that we created in setUp, including associated groups/repos
    // TODO: explicit deletion of associated groups/repos (above) is now superfluous since we are doing a hard delete
    userApi.deleteUser(gitlabManagerRestricted.getUser().getUserId(), true);
// GitLabServerManagerTest.awaitUserDeleted(userApi, gitlabManagerRestricted.getUser().getUserId());
}
Also used : GitLabApi(org.gitlab4j.api.GitLabApi) GroupApi(org.gitlab4j.api.GroupApi) ProjectApi(org.gitlab4j.api.ProjectApi) UserApi(org.gitlab4j.api.UserApi) AfterEach(org.junit.jupiter.api.AfterEach)

Aggregations

GroupApi (org.gitlab4j.api.GroupApi)6 IOException (java.io.IOException)4 GitLabApiException (org.gitlab4j.api.GitLabApiException)4 Group (org.gitlab4j.api.models.Group)3 GitLabApi (org.gitlab4j.api.GitLabApi)2 ProjectApi (org.gitlab4j.api.ProjectApi)2 UserApi (org.gitlab4j.api.UserApi)2 CreateRepositoryResponse (de.catma.repository.git.CreateRepositoryResponse)1 GitMember (de.catma.repository.git.GitMember)1 Member (org.gitlab4j.api.models.Member)1 Namespace (org.gitlab4j.api.models.Namespace)1 Project (org.gitlab4j.api.models.Project)1 AfterEach (org.junit.jupiter.api.AfterEach)1