public ProgressEvent handleRequest()

in aws-customerprofiles-domain/src/main/java/software/amazon/customerprofiles/domain/ListHandler.java [34:77]


    public ProgressEvent<ResourceModel, CallbackContext> handleRequest(
            final AmazonWebServicesClientProxy proxy,
            final ResourceHandlerRequest<ResourceModel> request,
            final CallbackContext callbackContext,
            final Logger logger) {

        if (this.client == null) {
            this.client = ClientBuilder.getClient();
        }

        final ListDomainsRequest listDomainsRequest = ListDomainsRequest.builder()
                .nextToken(request.getNextToken())
                .build();

        final ListDomainsResponse listDomainsResponse;
        try {
            listDomainsResponse = proxy.injectCredentialsAndInvokeV2(listDomainsRequest, client::listDomains);
        } catch (BadRequestException e) {
            throw new CfnInvalidRequestException(e);
        } catch (InternalServerException e) {
            throw new CfnServiceInternalErrorException(e);
        } catch (ResourceNotFoundException e) {
            throw new CfnNotFoundException(e);
        } catch (Exception e) {
            throw new CfnGeneralServiceException(e);
        }

        List<ResourceModel> responseModels = new ArrayList<>();
        listDomainsResponse.items().forEach(res -> {
            ResourceModel responseModel = ResourceModel.builder()
                    .createdAt(res.createdAt().toString())
                    .domainName(res.domainName())
                    .lastUpdatedAt(res.lastUpdatedAt().toString())
                    .tags(Translator.mapTagsToList(res.tags()))
                    .build();
            responseModels.add(responseModel);
        });

        return ProgressEvent.<ResourceModel, CallbackContext>builder()
                .resourceModels(responseModels)
                .status(OperationStatus.SUCCESS)
                .nextToken(listDomainsResponse.nextToken())
                .build();
    }