use of com.sequenceiq.environment.platformresource.PlatformResourceRequest in project cloudbreak by hortonworks.
the class CloudNetworkService method fetchCloudNetwork.
private Map<String, CloudSubnet> fetchCloudNetwork(Set<Region> regions, Credential credential, String cloudPlatform, NetworkDto network, Map<String, String> filter, Set<String> subnetIds) {
String regionName = regions.iterator().next().getName();
PlatformResourceRequest platformResourceRequest = new PlatformResourceRequest();
platformResourceRequest.setCredential(credential);
platformResourceRequest.setCloudPlatform(cloudPlatform);
platformResourceRequest.setRegion(regionName);
platformResourceRequest.setFilters(filter);
LOGGER.debug("About to fetch networks from cloud provider ({})...", cloudPlatform);
CloudNetworks cloudNetworks = platformParameterService.getCloudNetworks(platformResourceRequest);
Set<CloudNetwork> cloudNetworkSet = cloudNetworks.getCloudNetworkResponses().get(regionName);
return cloudNetworkSet.stream().flatMap(it -> it.getSubnetsMeta().stream()).filter(sn -> isNetworkIdMatches(subnetIds, sn, cloudPlatform) || isNetworkNameMatches(subnetIds, sn, cloudPlatform)).collect(toMap(getNetworkIdentifier(cloudPlatform), Function.identity()));
}
use of com.sequenceiq.environment.platformresource.PlatformResourceRequest in project cloudbreak by hortonworks.
the class EnvironmentService method getRegionsByEnvironment.
public CloudRegions getRegionsByEnvironment(Environment environment) {
PlatformResourceRequest platformResourceRequest = new PlatformResourceRequest();
platformResourceRequest.setCredential(environment.getCredential());
platformResourceRequest.setCloudPlatform(environment.getCloudPlatform());
return platformParameterService.getRegionsByCredential(platformResourceRequest, false);
}
use of com.sequenceiq.environment.platformresource.PlatformResourceRequest in project cloudbreak by hortonworks.
the class CredentialPlatformResourceControllerTest method getNoSqlTables.
@Test
void getNoSqlTables() {
CloudNoSqlTables noSqlTables = new CloudNoSqlTables();
PlatformResourceRequest platformResourceRequest = new PlatformResourceRequest();
PlatformNoSqlTablesResponse response = new PlatformNoSqlTablesResponse();
when(platformParameterService.getPlatformResourceRequest(any(), any(), any(), any(), any(), any())).thenReturn(platformResourceRequest);
when(platformParameterService.getNoSqlTables(any(PlatformResourceRequest.class))).thenReturn(noSqlTables);
when(cloudNoSqlTablesToPlatformNoSqlTablesV1ResponseConverter.convert(noSqlTables)).thenReturn(response);
doNothing().when(commonPermissionCheckingUtils).checkPermissionForUserOnResource(any(), any(), any());
PlatformNoSqlTablesResponse result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.getNoSqlTables(null, CREDENTIAL_CRN, "region", "aws", "az"));
verify(platformParameterService).getNoSqlTables(platformResourceRequest);
verify(cloudNoSqlTablesToPlatformNoSqlTablesV1ResponseConverter).convert(noSqlTables);
assertEquals(response, result);
}
use of com.sequenceiq.environment.platformresource.PlatformResourceRequest in project cloudbreak by hortonworks.
the class CredentialPlatformResourceController method getGatewaysCredentialId.
@Override
@CustomPermissionCheck
public PlatformGatewaysResponse getGatewaysCredentialId(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/gateways, request: {}", request);
CloudGateWays gateways = platformParameterService.getGatewaysCredentialId(request);
PlatformGatewaysResponse response = cloudGatewayssToPlatformGatewaysV1ResponseConverter.convert(gateways);
LOGGER.info("Resp /platform_resources/gateways, request: {}, ipPools: {}, response: {}", request, gateways, response);
return response;
}
use of com.sequenceiq.environment.platformresource.PlatformResourceRequest 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;
}
Aggregations