in aws-iotwireless-deviceprofile/src/main/java/software/amazon/iotwireless/deviceprofile/ListHandler.java [23:53]
public ProgressEvent<ResourceModel, CallbackContext> handleRequest(
final AmazonWebServicesClientProxy proxy,
final ResourceHandlerRequest<ResourceModel> request,
final CallbackContext callbackContext,
final ProxyClient<IotWirelessClient> proxyClient,
final Logger logger) {
final ResourceModel model = request.getDesiredResourceState();
final ListDeviceProfilesRequest listDeviceProfilesRequest = Translator.translateToListRequest(request.getNextToken());
try {
ListDeviceProfilesResponse listDeviceProfilesResponse = proxy.injectCredentialsAndInvokeV2(listDeviceProfilesRequest, proxyClient.client()::listDeviceProfiles);
final List<ResourceModel> models = listDeviceProfilesResponse.deviceProfileList().stream()
.map(deviceProfile -> ResourceModel.builder()
.id(deviceProfile.id())
.name(deviceProfile.name())
.arn(deviceProfile.arn())
.build())
.collect(Collectors.toList());
return ProgressEvent.<ResourceModel, CallbackContext>builder()
.resourceModels(models)
.nextToken(listDeviceProfilesResponse.nextToken())
.status(OperationStatus.SUCCESS)
.build();
} catch (final Exception e) {
throw handleException(e, listDeviceProfilesRequest);
}
}