Search in sources :

Example 26 with CheckPermissionByResourceCrn

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

the class ClusterTemplateV4Controller method getByCrn.

@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_CLUSTER_DEFINITION)
public ClusterTemplateV4Response getByCrn(Long workspaceId, @TenantAwareParam @ResourceCrn String crn) {
    boolean internalTenant = isInternalTenant();
    try {
        ClusterTemplate clusterTemplate = transactionService.required(() -> clusterTemplateService.getByCrn(crn, threadLocalService.getRequestedWorkspaceId(), internalTenant));
        ClusterTemplateV4Response response = transactionService.required(() -> clusterTemplateToClusterTemplateV4ResponseConverter.convert(clusterTemplate));
        if (!StringUtils.isEmpty(response.getEnvironmentCrn())) {
            environmentServiceDecorator.prepareEnvironment(response);
        } else {
            LOGGER.warn("Skipping response decoration with environment name. Environment CRN was empty.");
        }
        return response;
    } catch (TransactionExecutionException cse) {
        LOGGER.warn("Unable to find cluster definition due to {}", cse.getMessage());
        throw new CloudbreakServiceException("Unable to obtain cluster definition!");
    }
}
Also used : ClusterTemplateV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.responses.ClusterTemplateV4Response) ClusterTemplate(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterTemplate) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CheckPermissionByResourceCrn(com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)

Example 27 with CheckPermissionByResourceCrn

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

the class EnvironmentPlatformResourceController method getVmTypesByCredential.

@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)
public PlatformVmtypesResponse getVmTypesByCredential(@ResourceCrn String environmentCrn, String region, String platformVariant, String availabilityZone, CdpResourceType cdpResourceType) {
    String accountId = getAccountId();
    validateEnvironmentCrnPattern(environmentCrn);
    PlatformResourceRequest request = platformParameterService.getPlatformResourceRequestByEnvironment(accountId, environmentCrn, region, platformVariant, availabilityZone, null, null, cdpResourceType);
    LOGGER.info("Get /platform_resources/machine_types, request: {}", request);
    CloudVmTypes cloudVmTypes = platformParameterService.getVmTypesByCredential(request);
    PlatformVmtypesResponse response = cloudVmTypesToPlatformVmTypesV1ResponseConverter.convert(cloudVmTypes);
    LOGGER.info("Resp /platform_resources/machine_types, request: {}, cloudVmTypes: {}, response: {}", request, cloudVmTypes, response);
    return response;
}
Also used : CloudVmTypes(com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes) PlatformVmtypesResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformVmtypesResponse) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) CheckPermissionByResourceCrn(com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)

Example 28 with CheckPermissionByResourceCrn

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

the class EnvironmentPlatformResourceController method getGatewaysCredentialId.

@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)
public PlatformGatewaysResponse getGatewaysCredentialId(@ResourceCrn String environmentCrn, String region, String platformVariant, String availabilityZone) {
    String accountId = getAccountId();
    validateEnvironmentCrnPattern(environmentCrn);
    PlatformResourceRequest request = platformParameterService.getPlatformResourceRequestByEnvironment(accountId, environmentCrn, region, platformVariant, availabilityZone, null);
    LOGGER.info("Get /platform_resources/gateways, request: {}", request);
    CloudGateWays gateways = platformParameterService.getGatewaysCredentialId(request);
    PlatformGatewaysResponse response = cloudGatewayssToPlatformGatewaysV1ResponseConverter.convert(gateways);
    LOGGER.info("Resp /platform_resources/gateways, request: {}, ipPools: {}, response: {}", request, gateways, response);
    return response;
}
Also used : PlatformGatewaysResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformGatewaysResponse) CloudGateWays(com.sequenceiq.cloudbreak.cloud.model.CloudGateWays) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) CheckPermissionByResourceCrn(com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)

Example 29 with CheckPermissionByResourceCrn

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

the class EnvironmentPlatformResourceController method getIpPoolsCredentialId.

@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)
public PlatformIpPoolsResponse getIpPoolsCredentialId(@ResourceCrn String environmentCrn, String region, String platformVariant, String availabilityZone) {
    String accountId = getAccountId();
    validateEnvironmentCrnPattern(environmentCrn);
    PlatformResourceRequest request = platformParameterService.getPlatformResourceRequestByEnvironment(accountId, environmentCrn, region, platformVariant, availabilityZone, null);
    LOGGER.info("Get /platform_resources/ip_pools, request: {}", request);
    CloudIpPools ipPools = platformParameterService.getIpPoolsCredentialId(request);
    PlatformIpPoolsResponse response = cloudIpPoolsToPlatformIpPoolsV1ResponseConverter.convert(ipPools);
    LOGGER.info("Resp /platform_resources/ip_pools, request: {}, ipPools: {}, response: {}", request, ipPools, response);
    return response;
}
Also used : PlatformIpPoolsResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformIpPoolsResponse) CloudIpPools(com.sequenceiq.cloudbreak.cloud.model.CloudIpPools) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) CheckPermissionByResourceCrn(com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)

Example 30 with CheckPermissionByResourceCrn

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

the class EnvironmentPlatformResourceController method getEncryptionKeys.

@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)
public PlatformEncryptionKeysResponse getEncryptionKeys(@ResourceCrn String environmentCrn, String region, String platformVariant, String availabilityZone) {
    String accountId = getAccountId();
    validateEnvironmentCrnPattern(environmentCrn);
    PlatformResourceRequest request = platformParameterService.getPlatformResourceRequestByEnvironment(accountId, environmentCrn, region, platformVariant, availabilityZone, null);
    LOGGER.info("Get /platform_resources/encryption_keys, request: {}", request);
    CloudEncryptionKeys encryptionKeys = platformParameterService.getEncryptionKeys(request);
    PlatformEncryptionKeysResponse response = cloudEncryptionKeysToPlatformEncryptionKeysV1ResponseConverter.convert(encryptionKeys);
    LOGGER.info("Resp /platform_resources/encryption_keys, request: {}, ipPools: {}, response: {}", request, encryptionKeys, response);
    return response;
}
Also used : PlatformEncryptionKeysResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformEncryptionKeysResponse) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) CloudEncryptionKeys(com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKeys) CheckPermissionByResourceCrn(com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)

Aggregations

CheckPermissionByResourceCrn (com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)36 PlatformResourceRequest (com.sequenceiq.environment.platformresource.PlatformResourceRequest)12 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)7 ResourceCrn (com.sequenceiq.authorization.annotation.ResourceCrn)4 Crn (com.sequenceiq.cloudbreak.auth.crn.Crn)4 Credential (com.sequenceiq.environment.credential.domain.Credential)4 CloudAccessConfigs (com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfigs)3 CloudEncryptionKeys (com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKeys)3 CloudGateWays (com.sequenceiq.cloudbreak.cloud.model.CloudGateWays)3 CloudIpPools (com.sequenceiq.cloudbreak.cloud.model.CloudIpPools)3 CloudNetworks (com.sequenceiq.cloudbreak.cloud.model.CloudNetworks)3 CloudRegions (com.sequenceiq.cloudbreak.cloud.model.CloudRegions)3 CloudSecurityGroups (com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroups)3 CloudSshKeys (com.sequenceiq.cloudbreak.cloud.model.CloudSshKeys)3 CloudVmTypes (com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes)3 CloudNoSqlTables (com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables)3 PlatformAccessConfigsResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformAccessConfigsResponse)3 PlatformEncryptionKeysResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformEncryptionKeysResponse)3 PlatformGatewaysResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformGatewaysResponse)3 PlatformIpPoolsResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformIpPoolsResponse)3