Search in sources :

Example 1 with PlatformSshKeysResponse

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

the class CredentialPlatformResourceController method getCloudSshKeys.

@Override
@CustomPermissionCheck
public PlatformSshKeysResponse getCloudSshKeys(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/ssh_keys, request: {}", request);
    CloudSshKeys sshKeys = platformParameterService.getCloudSshKeys(request);
    PlatformSshKeysResponse response = cloudSshKeysToPlatformSshKeysV1ResponseConverter.convert(sshKeys);
    LOGGER.info("Resp /platform_resources/ssh_keys, request: {}, sshKeys: {}", request, sshKeys);
    return response;
}
Also used : CloudSshKeys(com.sequenceiq.cloudbreak.cloud.model.CloudSshKeys) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) PlatformSshKeysResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformSshKeysResponse) CustomPermissionCheck(com.sequenceiq.authorization.annotation.CustomPermissionCheck)

Example 2 with PlatformSshKeysResponse

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

the class EnvironmentPlatformResourceController method getCloudSshKeys.

@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)
public PlatformSshKeysResponse getCloudSshKeys(@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/ssh_keys, request: {}", request);
    CloudSshKeys sshKeys = platformParameterService.getCloudSshKeys(request);
    PlatformSshKeysResponse response = cloudSshKeysToPlatformSshKeysV1ResponseConverter.convert(sshKeys);
    LOGGER.info("Resp /platform_resources/ssh_keys, request: {}, sshKeys: {}, response: {}", request, sshKeys, response);
    return response;
}
Also used : CloudSshKeys(com.sequenceiq.cloudbreak.cloud.model.CloudSshKeys) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) PlatformSshKeysResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformSshKeysResponse) CheckPermissionByResourceCrn(com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)

Example 3 with PlatformSshKeysResponse

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

the class CloudSshKeysToPlatformSshKeysV1ResponseConverter method convert.

public PlatformSshKeysResponse convert(CloudSshKeys source) {
    Map<String, Set<PlatformSshKeyResponse>> result = new HashMap<>();
    for (Entry<String, Set<CloudSshKey>> entry : source.getCloudSshKeysResponses().entrySet()) {
        Set<PlatformSshKeyResponse> sshKeyResponses = new HashSet<>();
        for (CloudSshKey cloudSshKey : entry.getValue()) {
            PlatformSshKeyResponse actual = new PlatformSshKeyResponse(cloudSshKey.getName(), cloudSshKey.getProperties());
            sshKeyResponses.add(actual);
        }
        result.put(entry.getKey(), sshKeyResponses);
    }
    return new PlatformSshKeysResponse(result);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) CloudSshKey(com.sequenceiq.cloudbreak.cloud.model.CloudSshKey) PlatformSshKeysResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformSshKeysResponse) PlatformSshKeyResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformSshKeyResponse) HashSet(java.util.HashSet)

Aggregations

PlatformSshKeysResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformSshKeysResponse)3 CloudSshKeys (com.sequenceiq.cloudbreak.cloud.model.CloudSshKeys)2 PlatformResourceRequest (com.sequenceiq.environment.platformresource.PlatformResourceRequest)2 CheckPermissionByResourceCrn (com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)1 CustomPermissionCheck (com.sequenceiq.authorization.annotation.CustomPermissionCheck)1 CloudSshKey (com.sequenceiq.cloudbreak.cloud.model.CloudSshKey)1 PlatformSshKeyResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformSshKeyResponse)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1