Search in sources :

Example 6 with PolicyModel

use of bio.terra.model.PolicyModel in project jade-data-repo by DataBiosphere.

the class SamIam method deletePolicyMemberInner.

private PolicyModel deletePolicyMemberInner(AuthenticatedUserRequest userReq, IamResourceType iamResourceType, UUID resourceId, String policyName, String userEmail) throws ApiException {
    ResourcesApi samResourceApi = samResourcesApi(userReq.getRequiredToken());
    samResourceApi.removeUserFromPolicy(iamResourceType.toString(), resourceId.toString(), policyName, userEmail);
    AccessPolicyMembership result = samResourceApi.getPolicy(iamResourceType.toString(), resourceId.toString(), policyName);
    return new PolicyModel().name(policyName).members(result.getMemberEmails());
}
Also used : PolicyModel(bio.terra.model.PolicyModel) ResourcesApi(org.broadinstitute.dsde.workbench.client.sam.api.ResourcesApi) AccessPolicyMembership(org.broadinstitute.dsde.workbench.client.sam.model.AccessPolicyMembership)

Example 7 with PolicyModel

use of bio.terra.model.PolicyModel in project jade-data-repo by DataBiosphere.

the class RepositoryApiController method addDatasetPolicyMember.

// --dataset policies --
@Override
public ResponseEntity<PolicyResponse> addDatasetPolicyMember(@PathVariable("id") String id, @PathVariable("policyName") String policyName, @Valid @RequestBody PolicyMemberRequest policyMember) {
    PolicyModel policy = iamService.addPolicyMember(getAuthenticatedInfo(), IamResourceType.DATASET, UUID.fromString(id), policyName, policyMember.getEmail());
    PolicyResponse response = new PolicyResponse().policies(Collections.singletonList(policy));
    return new ResponseEntity<>(response, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) PolicyModel(bio.terra.model.PolicyModel) PolicyResponse(bio.terra.model.PolicyResponse)

Example 8 with PolicyModel

use of bio.terra.model.PolicyModel in project jade-data-repo by DataBiosphere.

the class RepositoryApiController method addSnapshotPolicyMember.

// --snapshot policies --
@Override
public ResponseEntity<PolicyResponse> addSnapshotPolicyMember(@PathVariable("id") String id, @PathVariable("policyName") String policyName, @Valid @RequestBody PolicyMemberRequest policyMember) {
    PolicyModel policy = iamService.addPolicyMember(getAuthenticatedInfo(), IamResourceType.DATASNAPSHOT, UUID.fromString(id), policyName, policyMember.getEmail());
    PolicyResponse response = new PolicyResponse().policies(Collections.singletonList(policy));
    return new ResponseEntity<>(response, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) PolicyModel(bio.terra.model.PolicyModel) PolicyResponse(bio.terra.model.PolicyResponse)

Aggregations

PolicyModel (bio.terra.model.PolicyModel)8 PolicyResponse (bio.terra.model.PolicyResponse)5 ResponseEntity (org.springframework.http.ResponseEntity)5 ResourcesApi (org.broadinstitute.dsde.workbench.client.sam.api.ResourcesApi)3 AccessPolicyMembership (org.broadinstitute.dsde.workbench.client.sam.model.AccessPolicyMembership)3 ValidationException (bio.terra.app.controller.exception.ValidationException)2 DataRepoException (bio.terra.common.exception.DataRepoException)1 UserStatusInfo (bio.terra.model.UserStatusInfo)1 ConfigurationService (bio.terra.service.configuration.ConfigurationService)1 AuthenticatedUserRequest (bio.terra.service.iam.AuthenticatedUserRequest)1 IamAction (bio.terra.service.iam.IamAction)1 IamProviderInterface (bio.terra.service.iam.IamProviderInterface)1 IamResourceType (bio.terra.service.iam.IamResourceType)1 IamRole (bio.terra.service.iam.IamRole)1 IamBadRequestException (bio.terra.service.iam.exception.IamBadRequestException)1 IamInternalServerErrorException (bio.terra.service.iam.exception.IamInternalServerErrorException)1 IamNotFoundException (bio.terra.service.iam.exception.IamNotFoundException)1 IamUnauthorizedException (bio.terra.service.iam.exception.IamUnauthorizedException)1 HttpStatusCodes (com.google.api.client.http.HttpStatusCodes)1 ArrayList (java.util.ArrayList)1