in aws-datasync-locationobjectstorage/src/main/java/software/amazon/datasync/locationobjectstorage/ListHandler.java [24:63]
public ProgressEvent<ResourceModel, CallbackContext> handleRequest(
final AmazonWebServicesClientProxy proxy,
final ResourceHandlerRequest<ResourceModel> request,
final CallbackContext callbackContext,
final Logger logger) {
final String nextToken = request.getNextToken();
final DataSyncClient client = ClientBuilder.getClient();
final ListLocationsRequest listLocationsRequest = Translator.translateToListRequest(nextToken);
final ListLocationsResponse response;
try {
response = proxy.injectCredentialsAndInvokeV2(listLocationsRequest, client::listLocations);
} catch (InvalidRequestException e) {
throw new CfnInvalidRequestException(e.getMessage(), e.getCause());
} catch (InternalException e) {
throw new CfnServiceInternalErrorException(e.getMessage(), e.getCause());
} catch (DataSyncException e) {
throw Translator.translateDataSyncExceptionToCfnException(e);
}
final List<ResourceModel> models = new ArrayList<>();
for (LocationListEntry loc : response.locations()) {
// Add only if it is an Object Storage location
if (loc.locationUri().startsWith("object-storage://")) {
ResourceModel model = ResourceModel.builder()
.locationArn(loc.locationArn())
.locationUri(loc.locationUri())
.build();
models.add(model);
}
}
return ProgressEvent.<ResourceModel, CallbackContext>builder()
.resourceModels(models)
.status(OperationStatus.SUCCESS)
.nextToken(response.nextToken())
.build();
}