Search in sources :

Example 1 with PolicyResponse

use of bio.terra.model.PolicyResponse 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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ValidationException(bio.terra.app.controller.exception.ValidationException) PolicyModel(bio.terra.model.PolicyModel) PolicyResponse(bio.terra.model.PolicyResponse)

Example 2 with PolicyResponse

use of bio.terra.model.PolicyResponse 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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) PolicyModel(bio.terra.model.PolicyModel) PolicyResponse(bio.terra.model.PolicyResponse)

Example 3 with PolicyResponse

use of bio.terra.model.PolicyResponse 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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ValidationException(bio.terra.app.controller.exception.ValidationException) PolicyModel(bio.terra.model.PolicyModel) PolicyResponse(bio.terra.model.PolicyResponse)

Example 4 with PolicyResponse

use of bio.terra.model.PolicyResponse 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 5 with PolicyResponse

use of bio.terra.model.PolicyResponse 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)5 PolicyResponse (bio.terra.model.PolicyResponse)5 ResponseEntity (org.springframework.http.ResponseEntity)5 ValidationException (bio.terra.app.controller.exception.ValidationException)2