Search in sources :

Example 16 with CheckPermissionByResourceName

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

the class SdxController method resize.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.RESIZE_DATALAKE)
public SdxClusterResponse resize(@ResourceName String name, SdxClusterResizeRequest resizeSdxClusterRequest) {
    String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
    Pair<SdxCluster, FlowIdentifier> result = sdxService.resizeSdx(userCrn, name, resizeSdxClusterRequest);
    SdxCluster sdxCluster = result.getLeft();
    metricService.incrementMetricCounter(MetricType.EXTERNAL_SDX_REQUESTED, sdxCluster);
    SdxClusterResponse sdxClusterResponse = sdxClusterConverter.sdxClusterToResponse(sdxCluster);
    sdxClusterResponse.setName(sdxCluster.getClusterName());
    sdxClusterResponse.setFlowIdentifier(result.getRight());
    return sdxClusterResponse;
}
Also used : SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Example 17 with CheckPermissionByResourceName

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

the class SdxBackupController method backupDatabaseByName.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.BACKUP_DATALAKE)
public SdxDatabaseBackupResponse backupDatabaseByName(@ResourceName String name, String backupId, String backupLocation) {
    SdxCluster sdxCluster = getSdxClusterByName(name);
    try {
        SdxDatabaseBackupStatusResponse response = sdxBackupRestoreService.getDatabaseBackupStatus(sdxCluster, backupId);
        SdxDatabaseBackupResponse sdxDatabaseBackupResponse = new SdxDatabaseBackupResponse();
        sdxDatabaseBackupResponse.setOperationId(backupId);
        return sdxDatabaseBackupResponse;
    } catch (NotFoundException notFoundException) {
        SdxDatabaseBackupRequest backupRequest = new SdxDatabaseBackupRequest();
        backupRequest.setBackupId(backupId);
        backupRequest.setBackupLocation(backupLocation);
        backupRequest.setCloseConnections(true);
        return sdxBackupRestoreService.triggerDatabaseBackup(sdxCluster, backupRequest);
    }
}
Also used : SdxDatabaseBackupStatusResponse(com.sequenceiq.sdx.api.model.SdxDatabaseBackupStatusResponse) SdxDatabaseBackupRequest(com.sequenceiq.sdx.api.model.SdxDatabaseBackupRequest) 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 18 with CheckPermissionByResourceName

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

the class SdxController method getDetail.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.DESCRIBE_DETAILED_DATALAKE)
public SdxClusterDetailResponse getDetail(@ResourceName String name, Set<String> entries) {
    SdxCluster sdxCluster = getSdxClusterByName(name);
    StackV4Response stackV4Response = sdxService.getDetail(name, entries, sdxCluster.getAccountId());
    SdxClusterResponse sdxClusterResponse = sdxClusterConverter.sdxClusterToResponse(sdxCluster);
    return SdxClusterDetailResponse.create(sdxClusterResponse, stackV4Response);
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Example 19 with CheckPermissionByResourceName

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

the class ImageCatalogV4Controller method getImageByCatalogNameAndImageId.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.DESCRIBE_IMAGE_CATALOG)
public ImagesV4Response getImageByCatalogNameAndImageId(Long workspaceId, @ResourceName String name, String imageId, @AccountId String accountId) throws Exception {
    StatedImage statedImage = imageCatalogService.getImageByCatalogName(restRequestThreadLocalService.getRequestedWorkspaceId(), imageId, name);
    Images images = new Images(List.of(), List.of(statedImage.getImage()), List.of(), Set.of());
    return imagesToImagesV4ResponseConverter.convert(images);
}
Also used : Images(com.sequenceiq.cloudbreak.cloud.model.catalog.Images) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Example 20 with CheckPermissionByResourceName

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

the class RecipesV4Controller method deleteByName.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.DELETE_RECIPE)
public RecipeV4Response deleteByName(Long workspaceId, @ResourceName String name) {
    Recipe deleted = recipeService.delete(NameOrCrn.ofName(name), restRequestThreadLocalService.getRequestedWorkspaceId());
    notify(ResourceEvent.RECIPE_DELETED);
    return recipeToRecipeV4ResponseConverter.convert(deleted);
}
Also used : Recipe(com.sequenceiq.cloudbreak.domain.Recipe) 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