protected ProgressEvent handleRequest()

in aws-ec2-enclavecertificateiamroleassociation/src/main/java/software/amazon/ec2/enclavecertificateiamroleassociation/ReadHandler.java [15:50]


    protected ProgressEvent<ResourceModel, CallbackContext> handleRequest(AmazonWebServicesClientProxy proxy,
                                                                          ResourceHandlerRequest<ResourceModel> request,
                                                                          CallbackContext callbackContext,
                                                                          ProxyClient<Ec2Client> proxyClient,
                                                                          Logger logger) {
        final ResourceModel model = request.getDesiredResourceState();

        try {
            validateNotNull(model.getCertificateArn(), Properties.CertificateArn);
            validateNotNull(model.getRoleArn(), Properties.RoleArn);

            AssociatedRole associatedRole = Helper.getAssociatedRole(proxyClient,
                    model.getCertificateArn(), model.getRoleArn());
            if (associatedRole != null) {
                    model.setCertificateS3BucketName(associatedRole.certificateS3BucketName());
                    model.setCertificateS3ObjectKey(associatedRole.certificateS3ObjectKey());
                    model.setEncryptionKmsKeyId(associatedRole.encryptionKmsKeyId());

                    return ProgressEvent.<ResourceModel, CallbackContext>builder()
                            .resourceModel(model)
                            .status(OperationStatus.SUCCESS)
                            .build();
            }

            return ProgressEvent.<ResourceModel, CallbackContext>builder()
                    .resourceModel(model)
                    .message(String.format("No association found for certificate arn %s and" +
                                    " role arn %s",
                            model.getCertificateArn(), model.getRoleArn()))
                    .status(OperationStatus.FAILED)
                    .errorCode(HandlerErrorCode.NotFound)
                    .build();
        } catch (final Throwable e) {
            return handleException(e, logger);
        }
    }