Search in sources :

Example 1 with PlatformNetworksResponse

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

the class CredentialPlatformResourceController method getCloudNetworks.

@Override
@CustomPermissionCheck
public PlatformNetworksResponse getCloudNetworks(String credentialName, String credentialCrn, String region, String platformVariant, String availabilityZone, String networkId, String subnetIds, String sharedProjectId) {
    customCheckUtil.run(() -> permissionCheckByCredential(credentialName, credentialCrn));
    String accountId = getAccountId();
    Map<String, String> filter = new HashMap<>();
    if (!Strings.isNullOrEmpty(subnetIds)) {
        filter.put(NetworkConstants.SUBNET_IDS, subnetIds);
    }
    if (!Strings.isNullOrEmpty(networkId)) {
        filter.put("networkId", networkId);
    }
    PlatformResourceRequest request = platformParameterService.getPlatformResourceRequest(accountId, credentialName, credentialCrn, region, platformVariant, availabilityZone, sharedProjectId, filter, null, CdpResourceType.DEFAULT);
    LOGGER.info("Get /platform_resources/networks, request: {}", request);
    CloudNetworks networks = platformParameterService.getCloudNetworks(request);
    PlatformNetworksResponse response = cloudNetworksToPlatformNetworksV1ResponseConverter.convert(networks);
    LOGGER.info("Resp /platform_resources/networks, request: {}, networks: {}, response: {}", request, networks, response);
    return response;
}
Also used : HashMap(java.util.HashMap) CloudNetworks(com.sequenceiq.cloudbreak.cloud.model.CloudNetworks) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) PlatformNetworksResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformNetworksResponse) CustomPermissionCheck(com.sequenceiq.authorization.annotation.CustomPermissionCheck)

Example 2 with PlatformNetworksResponse

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

the class EnvironmentPlatformResourceController method getCloudNetworks.

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

Example 3 with PlatformNetworksResponse

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

the class CloudNetworksToPlatformNetworksV1ResponseConverter method convert.

public PlatformNetworksResponse convert(CloudNetworks source) {
    Map<String, Set<PlatformNetworkResponse>> result = new HashMap<>();
    for (Entry<String, Set<CloudNetwork>> entry : source.getCloudNetworkResponses().entrySet()) {
        Set<PlatformNetworkResponse> networks = new HashSet<>();
        for (CloudNetwork cloudNetwork : entry.getValue()) {
            PlatformNetworkResponse actual = new PlatformNetworkResponse(cloudNetwork.getName(), cloudNetwork.getId(), cloudNetwork.getSubnets(), cloudNetwork.getSubnetsWithMetadata(), cloudNetwork.getProperties());
            networks.add(actual);
        }
        result.put(entry.getKey(), networks);
    }
    return new PlatformNetworksResponse(result);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) PlatformNetworkResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformNetworkResponse) PlatformNetworksResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformNetworksResponse) CloudNetwork(com.sequenceiq.cloudbreak.cloud.model.CloudNetwork) HashSet(java.util.HashSet)

Aggregations

PlatformNetworksResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformNetworksResponse)3 CloudNetworks (com.sequenceiq.cloudbreak.cloud.model.CloudNetworks)2 PlatformResourceRequest (com.sequenceiq.environment.platformresource.PlatformResourceRequest)2 HashMap (java.util.HashMap)2 CheckPermissionByResourceCrn (com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)1 CustomPermissionCheck (com.sequenceiq.authorization.annotation.CustomPermissionCheck)1 CloudNetwork (com.sequenceiq.cloudbreak.cloud.model.CloudNetwork)1 PlatformNetworkResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformNetworkResponse)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1