use of com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables in project cloudbreak by hortonworks.
the class CredentialPlatformResourceController method getNoSqlTables.
@Override
@CustomPermissionCheck
public PlatformNoSqlTablesResponse getNoSqlTables(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/nosql_tables, request: {}", request);
CloudNoSqlTables noSqlTables = platformParameterService.getNoSqlTables(request);
PlatformNoSqlTablesResponse response = cloudNoSqlTablesToPlatformNoSqlTablesV1ResponseConverter.convert(noSqlTables);
LOGGER.info("Resp /platform_resources/nosql_tables, request: {}, noSqlTables: {}, response: {}", request, noSqlTables, response);
return response;
}
use of com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables in project cloudbreak by hortonworks.
the class EnvironmentPlatformResourceController method getNoSqlTables.
@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)
public PlatformNoSqlTablesResponse getNoSqlTables(@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/nosql_tables, request: {}", request);
CloudNoSqlTables noSqlTables = platformParameterService.getNoSqlTables(request);
PlatformNoSqlTablesResponse response = cloudNoSqlTablesToPlatformNoSqlTablesV1ResponseConverter.convert(noSqlTables);
LOGGER.info("Resp /platform_resources/nosql_tables, request: {}, noSqlTables: {}, response: {}", request, noSqlTables, response);
return response;
}
use of com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables in project cloudbreak by hortonworks.
the class CloudNoSqlTablesToPlatformNoSqlTablesV1ResponseConverterTest method convert.
@Test
void convert() {
List<CloudNoSqlTable> tables = List.of(new CloudNoSqlTable("a"), new CloudNoSqlTable("b"));
CloudNoSqlTables source = new CloudNoSqlTables(tables);
PlatformNoSqlTablesResponse result = underTest.convert(source);
List<PlatformNoSqlTableResponse> noSqlTables = result.getNoSqlTables();
assertNotNull(noSqlTables);
assertEquals(tables.size(), noSqlTables.size());
tables.forEach(t -> {
assertTrue(noSqlTables.stream().anyMatch(s -> t.getName().equals(s.getName())));
});
}
use of com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables in project cloudbreak by hortonworks.
the class GetPlatformNoSqlTablesHandler method accept.
@Override
public void accept(Event<GetPlatformNoSqlTablesRequest> event) {
LOGGER.debug("Received event: {}", event);
GetPlatformNoSqlTablesRequest request = event.getData();
try {
CloudPlatformVariant cloudPlatformVariant = new CloudPlatformVariant(Platform.platform(request.getExtendedCloudCredential().getCloudPlatform()), Variant.variant(request.getVariant()));
CloudNoSqlTables cloudNoSqlTables = cloudPlatformConnectors.get(cloudPlatformVariant).platformResources().noSqlTables(request.getExtendedCloudCredential(), Region.region(request.getRegion()), request.getFilters());
GetPlatformNoSqlTablesResult result = new GetPlatformNoSqlTablesResult(request.getResourceId(), cloudNoSqlTables);
request.getResult().onNext(result);
LOGGER.debug("Query platform NoSQL tables finished.");
} catch (RuntimeException e) {
request.getResult().onNext(new GetPlatformNoSqlTablesResult(e.getMessage(), e, request.getResourceId()));
}
}
use of com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables in project cloudbreak by hortonworks.
the class AwsPlatformResources method noSqlTables.
@Override
public CloudNoSqlTables noSqlTables(ExtendedCloudCredential cloudCredential, Region region, Map<String, String> filters) {
List<CloudNoSqlTable> noSqlTables = new ArrayList<>();
AmazonDynamoDBClient dynamoDbClient = getAmazonDynamoDBClient(cloudCredential, region);
ListTablesRequest listTablesRequest = new ListTablesRequest();
ListTablesResult listTablesResult = null;
boolean first = true;
while (first || !isNullOrEmpty(listTablesResult.getLastEvaluatedTableName())) {
first = false;
listTablesRequest.setExclusiveStartTableName(listTablesResult == null ? null : listTablesResult.getLastEvaluatedTableName());
listTablesResult = dynamoDbClient.listTables(listTablesRequest);
List<String> partialTableNames = listTablesResult.getTableNames();
List<CloudNoSqlTable> partialResult = partialTableNames.stream().map(CloudNoSqlTable::new).collect(Collectors.toList());
noSqlTables.addAll(partialResult);
}
return new CloudNoSqlTables(noSqlTables);
}
Aggregations