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