Search in sources :

Example 11 with CheckPermissionByResourceName

use of com.sequenceiq.authorization.annotation.CheckPermissionByResourceName in project cloudbreak by hortonworks.

the class CredentialV1Controller method getByName.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.DESCRIBE_CREDENTIAL)
public CredentialResponse getByName(@ResourceName String credentialName) {
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    Credential credential = credentialService.getByNameForAccountId(credentialName, accountId, ENVIRONMENT);
    return credentialConverter.convert(credential);
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Example 12 with CheckPermissionByResourceName

use of com.sequenceiq.authorization.annotation.CheckPermissionByResourceName in project cloudbreak by hortonworks.

the class DistroXV1Controller method putScalingByName.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.SCALE_DATAHUB)
public FlowIdentifier putScalingByName(@ResourceName String name, @Valid DistroXScaleV1Request updateRequest) {
    StackScaleV4Request stackScaleV4Request = scaleRequestConverter.convert(updateRequest);
    stackScaleV4Request.setStackId(stackOperations.getStackByName(name).getId());
    return stackOperations.putScaling(NameOrCrn.ofName(name), getWorkspaceIdForCurrentUser(), stackScaleV4Request);
}
Also used : StackScaleV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackScaleV4Request) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Example 13 with CheckPermissionByResourceName

use of com.sequenceiq.authorization.annotation.CheckPermissionByResourceName in project cloudbreak by hortonworks.

the class SdxRestoreController method restoreDatabaseByName.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.RESTORE_DATALAKE)
public SdxDatabaseRestoreResponse restoreDatabaseByName(@ResourceName String name, String backupId, String restoreId, String backupLocation) {
    SdxCluster sdxCluster = getSdxClusterByName(name);
    try {
        sdxBackupRestoreService.getDatabaseRestoreStatus(sdxCluster, restoreId);
        SdxDatabaseRestoreResponse sdxDatabaseRestoreResponse = new SdxDatabaseRestoreResponse();
        sdxDatabaseRestoreResponse.setOperationId(restoreId);
        return sdxDatabaseRestoreResponse;
    } catch (NotFoundException notFoundException) {
        return sdxBackupRestoreService.triggerDatabaseRestore(sdxCluster, backupId, restoreId, backupLocation);
    }
}
Also used : SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) SdxDatabaseRestoreResponse(com.sequenceiq.sdx.api.model.SdxDatabaseRestoreResponse) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Example 14 with CheckPermissionByResourceName

use of com.sequenceiq.authorization.annotation.CheckPermissionByResourceName in project cloudbreak by hortonworks.

the class SdxBackupController method backupDatabaseByNameInternal.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.BACKUP_DATALAKE)
public SdxDatabaseBackupResponse backupDatabaseByNameInternal(@ResourceName String name, SdxDatabaseBackupRequest backupRequest) {
    SdxCluster sdxCluster = getSdxClusterByName(name);
    String backupId = backupRequest.getBackupId();
    try {
        SdxDatabaseBackupStatusResponse response = sdxBackupRestoreService.getDatabaseBackupStatus(sdxCluster, backupId);
        SdxDatabaseBackupResponse sdxDatabaseBackupResponse = new SdxDatabaseBackupResponse();
        sdxDatabaseBackupResponse.setOperationId(backupId);
        return sdxDatabaseBackupResponse;
    } catch (NotFoundException notFoundException) {
        return sdxBackupRestoreService.triggerDatabaseBackup(sdxCluster, backupRequest);
    }
}
Also used : SdxDatabaseBackupStatusResponse(com.sequenceiq.sdx.api.model.SdxDatabaseBackupStatusResponse) SdxDatabaseBackupResponse(com.sequenceiq.sdx.api.model.SdxDatabaseBackupResponse) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Example 15 with CheckPermissionByResourceName

use of com.sequenceiq.authorization.annotation.CheckPermissionByResourceName in project cloudbreak by hortonworks.

the class SdxController method changeImageCatalog.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.CHANGE_IMAGE_CATALOG_DATALAKE)
@CheckPermissionByRequestProperty(type = NAME, path = "imageCatalog", action = DESCRIBE_IMAGE_CATALOG)
public void changeImageCatalog(@ResourceName String name, @RequestObject SdxChangeImageCatalogRequest changeImageCatalogRequest) {
    SdxCluster sdxCluster = getSdxClusterByName(name);
    sdxImageCatalogService.changeImageCatalog(sdxCluster, changeImageCatalogRequest.getImageCatalog());
}
Also used : SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) CheckPermissionByRequestProperty(com.sequenceiq.authorization.annotation.CheckPermissionByRequestProperty) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Aggregations

CheckPermissionByResourceName (com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)29 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)7 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)6 Credential (com.sequenceiq.environment.credential.domain.Credential)4 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)3 CustomImage (com.sequenceiq.cloudbreak.domain.CustomImage)3 CheckPermissionByRequestProperty (com.sequenceiq.authorization.annotation.CheckPermissionByRequestProperty)2 Images (com.sequenceiq.cloudbreak.cloud.model.catalog.Images)2 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)2 SdxClusterResponse (com.sequenceiq.sdx.api.model.SdxClusterResponse)2 SdxDatabaseBackupResponse (com.sequenceiq.sdx.api.model.SdxDatabaseBackupResponse)2 SdxDatabaseBackupStatusResponse (com.sequenceiq.sdx.api.model.SdxDatabaseBackupStatusResponse)2 ClusterTemplateV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.responses.ClusterTemplateV4Response)1 CustomImageCatalogV4GetImageResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4GetImageResponse)1 ImageCatalogV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageCatalogV4Response)1 StackScaleV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackScaleV4Request)1 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)1 ParametersQueryV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ParametersQueryV4Response)1 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1