Search in sources :

Example 1 with PlatformSecurityGroupsResponse

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

the class EnvironmentPlatformResourceController method getSecurityGroups.

@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)
public PlatformSecurityGroupsResponse getSecurityGroups(@ResourceCrn String environmentCrn, String region, String platformVariant, String availabilityZone, String sharedProjectId) {
    String accountId = getAccountId();
    validateEnvironmentCrnPattern(environmentCrn);
    PlatformResourceRequest request = platformParameterService.getPlatformResourceRequestByEnvironment(accountId, environmentCrn, region, platformVariant, availabilityZone, sharedProjectId);
    LOGGER.info("Get /platform_resources/security_groups, request: {}", request);
    CloudSecurityGroups securityGroups = platformParameterService.getSecurityGroups(request);
    PlatformSecurityGroupsResponse response = cloudSecurityGroupsToPlatformSecurityGroupsV1ResponseConverter.convert(securityGroups);
    LOGGER.info("Resp /platform_resources/security_groups, request: {}, securityGroups: {}, response: {}", request, securityGroups, response);
    return response;
}
Also used : CloudSecurityGroups(com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroups) PlatformSecurityGroupsResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformSecurityGroupsResponse) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) CheckPermissionByResourceCrn(com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)

Example 2 with PlatformSecurityGroupsResponse

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

the class CredentialPlatformResourceController method getSecurityGroups.

@Override
@CustomPermissionCheck
public PlatformSecurityGroupsResponse getSecurityGroups(String credentialName, String credentialCrn, String region, String platformVariant, String availabilityZone, String sharedProjectId) {
    customCheckUtil.run(() -> permissionCheckByCredential(credentialName, credentialCrn));
    String accountId = getAccountId();
    PlatformResourceRequest request = platformParameterService.getPlatformResourceRequest(accountId, credentialName, credentialCrn, region, platformVariant, availabilityZone, sharedProjectId);
    LOGGER.info("Get /platform_resources/security_groups, request: {}", request);
    CloudSecurityGroups securityGroups = platformParameterService.getSecurityGroups(request);
    PlatformSecurityGroupsResponse response = cloudSecurityGroupsToPlatformSecurityGroupsV1ResponseConverter.convert(securityGroups);
    LOGGER.info("Resp /platform_resources/security_groups, request: {}, securityGroups: {}, response: {}", request, securityGroups, response);
    return response;
}
Also used : CloudSecurityGroups(com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroups) PlatformSecurityGroupsResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformSecurityGroupsResponse) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) CustomPermissionCheck(com.sequenceiq.authorization.annotation.CustomPermissionCheck)

Example 3 with PlatformSecurityGroupsResponse

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

the class CloudSecurityGroupsToPlatformSecurityGroupsV1ResponseConverter method convert.

public PlatformSecurityGroupsResponse convert(CloudSecurityGroups source) {
    Map<String, Set<PlatformSecurityGroupResponse>> result = new HashMap<>();
    for (Entry<String, Set<CloudSecurityGroup>> entry : source.getCloudSecurityGroupsResponses().entrySet()) {
        Set<PlatformSecurityGroupResponse> securityGroupResponses = new HashSet<>();
        for (CloudSecurityGroup securityGroup : entry.getValue()) {
            PlatformSecurityGroupResponse actual = new PlatformSecurityGroupResponse(securityGroup.getGroupName(), securityGroup.getGroupId(), securityGroup.getProperties());
            securityGroupResponses.add(actual);
        }
        result.put(entry.getKey(), securityGroupResponses);
    }
    return new PlatformSecurityGroupsResponse(result);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) PlatformSecurityGroupsResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformSecurityGroupsResponse) PlatformSecurityGroupResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformSecurityGroupResponse) CloudSecurityGroup(com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroup) HashSet(java.util.HashSet)

Aggregations

PlatformSecurityGroupsResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformSecurityGroupsResponse)3 CloudSecurityGroups (com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroups)2 PlatformResourceRequest (com.sequenceiq.environment.platformresource.PlatformResourceRequest)2 CheckPermissionByResourceCrn (com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)1 CustomPermissionCheck (com.sequenceiq.authorization.annotation.CustomPermissionCheck)1 CloudSecurityGroup (com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroup)1 PlatformSecurityGroupResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformSecurityGroupResponse)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1