Search in sources :

Example 1 with PlatformEncryptionKeysResponse

use of com.sequenceiq.environment.api.v1.platformresource.model.PlatformEncryptionKeysResponse in project cloudbreak by hortonworks.

the class PlatformResourceClientService method getEncryptionKeys.

public CloudEncryptionKeys getEncryptionKeys(String envCrn, String region) {
    LOGGER.info("Fetch encryption keys by environment crn: {} and region: {}", envCrn, region);
    PlatformEncryptionKeysResponse encryptionKeys = environmentPlatformResourceEndpoint.getEncryptionKeys(envCrn, region, null, null);
    Set<CloudEncryptionKey> keys = encryptionKeys.getEncryptionKeyConfigs().stream().map(response -> new CloudEncryptionKey(response.getName(), response.getId(), response.getDescription(), response.getDisplayName(), response.getProperties())).collect(Collectors.toSet());
    return new CloudEncryptionKeys(keys);
}
Also used : PlatformEncryptionKeysResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformEncryptionKeysResponse) CloudEncryptionKey(com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKey) Inject(javax.inject.Inject) Logger(org.slf4j.Logger) Service(org.springframework.stereotype.Service) LoggerFactory(org.slf4j.LoggerFactory) CloudEncryptionKeys(com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKeys) Set(java.util.Set) EnvironmentPlatformResourceEndpoint(com.sequenceiq.environment.api.v1.platformresource.EnvironmentPlatformResourceEndpoint) PlatformEncryptionKeysResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformEncryptionKeysResponse) CloudEncryptionKey(com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKey) Collectors(java.util.stream.Collectors) CloudEncryptionKeys(com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKeys)

Example 2 with PlatformEncryptionKeysResponse

use of com.sequenceiq.environment.api.v1.platformresource.model.PlatformEncryptionKeysResponse in project cloudbreak by hortonworks.

the class CloudEncryptionKeysToPlatformEncryptionKeysV1ResponseConverter method convert.

public PlatformEncryptionKeysResponse convert(CloudEncryptionKeys source) {
    PlatformEncryptionKeysResponse platformEncryptionKeysResponse = new PlatformEncryptionKeysResponse();
    Set<EncryptionKeyConfigResponse> result = new HashSet<>();
    for (CloudEncryptionKey entry : source.getCloudEncryptionKeys()) {
        EncryptionKeyConfigResponse actual = new EncryptionKeyConfigResponse(entry.getName(), entry.getId(), entry.getDescription(), entry.getDisplayName(), entry.getProperties());
        result.add(actual);
    }
    platformEncryptionKeysResponse.setEncryptionKeyConfigs(result);
    return platformEncryptionKeysResponse;
}
Also used : PlatformEncryptionKeysResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformEncryptionKeysResponse) CloudEncryptionKey(com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKey) EncryptionKeyConfigResponse(com.sequenceiq.environment.api.v1.platformresource.model.EncryptionKeyConfigResponse) HashSet(java.util.HashSet)

Example 3 with PlatformEncryptionKeysResponse

use of com.sequenceiq.environment.api.v1.platformresource.model.PlatformEncryptionKeysResponse in project cloudbreak by hortonworks.

the class CredentialPlatformResourceController method getEncryptionKeys.

@Override
@CustomPermissionCheck
public PlatformEncryptionKeysResponse getEncryptionKeys(String credentialName, String credentialCrn, String region, String platformVariant, String availabilityZone) {
    customCheckUtil.run(() -> permissionCheckByCredential(credentialName, credentialCrn));
    String accountId = getAccountId();
    PlatformResourceRequest request = platformParameterService.getPlatformResourceRequest(accountId, credentialName, credentialCrn, region, platformVariant, availabilityZone);
    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) CustomPermissionCheck(com.sequenceiq.authorization.annotation.CustomPermissionCheck)

Example 4 with PlatformEncryptionKeysResponse

use of com.sequenceiq.environment.api.v1.platformresource.model.PlatformEncryptionKeysResponse 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

PlatformEncryptionKeysResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformEncryptionKeysResponse)4 CloudEncryptionKeys (com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKeys)3 CloudEncryptionKey (com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKey)2 PlatformResourceRequest (com.sequenceiq.environment.platformresource.PlatformResourceRequest)2 CheckPermissionByResourceCrn (com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)1 CustomPermissionCheck (com.sequenceiq.authorization.annotation.CustomPermissionCheck)1 EnvironmentPlatformResourceEndpoint (com.sequenceiq.environment.api.v1.platformresource.EnvironmentPlatformResourceEndpoint)1 EncryptionKeyConfigResponse (com.sequenceiq.environment.api.v1.platformresource.model.EncryptionKeyConfigResponse)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Service (org.springframework.stereotype.Service)1