use of bio.terra.model.PolicyModel in project jade-data-repo by DataBiosphere.
the class SamIam method addPolicyMemberInner.
private PolicyModel addPolicyMemberInner(AuthenticatedUserRequest userReq, IamResourceType iamResourceType, UUID resourceId, String policyName, String userEmail) throws ApiException {
ResourcesApi samResourceApi = samResourcesApi(userReq.getRequiredToken());
samResourceApi.addUserToPolicy(iamResourceType.toString(), resourceId.toString(), policyName, userEmail);
AccessPolicyMembership result = samResourceApi.getPolicy(iamResourceType.toString(), resourceId.toString(), policyName);
return new PolicyModel().name(policyName).members(result.getMemberEmails());
}
use of bio.terra.model.PolicyModel in project jade-data-repo by DataBiosphere.
the class RepositoryApiController method deleteDatasetPolicyMember.
@Override
public ResponseEntity<PolicyResponse> deleteDatasetPolicyMember(@PathVariable("id") String id, @PathVariable("policyName") String policyName, @PathVariable("memberEmail") String memberEmail) {
// member email can't be null since it is part of the URL
if (!ValidationUtils.isValidEmail(memberEmail)) {
throw new ValidationException("InvalidMemberEmail");
}
PolicyModel policy = iamService.deletePolicyMember(getAuthenticatedInfo(), IamResourceType.DATASET, UUID.fromString(id), policyName, memberEmail);
PolicyResponse response = new PolicyResponse().policies(Collections.singletonList(policy));
return new ResponseEntity<>(response, HttpStatus.OK);
}
use of bio.terra.model.PolicyModel in project jade-data-repo by DataBiosphere.
the class RepositoryApiController method retrieveDatasetPolicies.
@Override
public ResponseEntity<PolicyResponse> retrieveDatasetPolicies(@PathVariable("id") String id) {
List<PolicyModel> policies = iamService.retrievePolicies(getAuthenticatedInfo(), IamResourceType.DATASET, UUID.fromString(id));
PolicyResponse response = new PolicyResponse().policies(policies);
return new ResponseEntity<>(response, HttpStatus.OK);
}
use of bio.terra.model.PolicyModel in project jade-data-repo by DataBiosphere.
the class RepositoryApiController method deleteSnapshotPolicyMember.
@Override
public ResponseEntity<PolicyResponse> deleteSnapshotPolicyMember(@PathVariable("id") String id, @PathVariable("policyName") String policyName, @PathVariable("memberEmail") String memberEmail) {
// member email can't be null since it is part of the URL
if (!ValidationUtils.isValidEmail(memberEmail)) {
throw new ValidationException("InvalidMemberEmail");
}
PolicyModel policy = iamService.deletePolicyMember(getAuthenticatedInfo(), IamResourceType.DATASNAPSHOT, UUID.fromString(id), policyName, memberEmail);
PolicyResponse response = new PolicyResponse().policies(Collections.singletonList(policy));
return new ResponseEntity<>(response, HttpStatus.OK);
}
use of bio.terra.model.PolicyModel in project jade-data-repo by DataBiosphere.
the class SamIam method retrievePoliciesInner.
private List<PolicyModel> retrievePoliciesInner(AuthenticatedUserRequest userReq, IamResourceType iamResourceType, UUID resourceId) throws ApiException {
ResourcesApi samResourceApi = samResourcesApi(userReq.getRequiredToken());
List<AccessPolicyResponseEntry> results = samResourceApi.listResourcePolicies(iamResourceType.toString(), resourceId.toString());
return results.stream().map(entry -> new PolicyModel().name(entry.getPolicyName()).members(entry.getPolicy().getMemberEmails())).collect(Collectors.toList());
}
Aggregations