Search in sources :

Example 1 with AssignedUserGroupRequest

use of com.synopsys.integration.blackduck.api.manual.temporary.component.AssignedUserGroupRequest in project blackduck-common by blackducksoftware.

the class ProjectUsersService method addGroupToProject.

public void addGroupToProject(ProjectView projectView, String groupName) throws IntegrationException {
    Optional<UserGroupView> optionalUserGroupView = userGroupService.getGroupByName(groupName);
    UserGroupView userGroupView = optionalUserGroupView.orElseThrow(() -> new IntegrationException(String.format("The supplied group name (%s) does not exist.", groupName)));
    HttpUrl userGroupUrl = userGroupView.getHref();
    HttpUrl createUrl = projectView.getFirstLink(ProjectView.USERGROUPS_LINK);
    AssignedUserGroupRequest userGroupRequest = new AssignedUserGroupRequest();
    userGroupRequest.setGroup(userGroupUrl.string());
    blackDuckApiClient.post(createUrl, userGroupRequest);
}
Also used : AssignedUserGroupRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.AssignedUserGroupRequest) UserGroupView(com.synopsys.integration.blackduck.api.generated.view.UserGroupView) AssignedUserGroupView(com.synopsys.integration.blackduck.api.manual.temporary.response.AssignedUserGroupView) IntegrationException(com.synopsys.integration.exception.IntegrationException) BlackDuckIntegrationException(com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException) HttpUrl(com.synopsys.integration.rest.HttpUrl)

Aggregations

UserGroupView (com.synopsys.integration.blackduck.api.generated.view.UserGroupView)1 AssignedUserGroupRequest (com.synopsys.integration.blackduck.api.manual.temporary.component.AssignedUserGroupRequest)1 AssignedUserGroupView (com.synopsys.integration.blackduck.api.manual.temporary.response.AssignedUserGroupView)1 BlackDuckIntegrationException (com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1 HttpUrl (com.synopsys.integration.rest.HttpUrl)1