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;
}
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;
}
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);
}
Aggregations