protected ProgressEvent handleRequest()

in aws-sso-permissionset/src/main/java/software/amazon/sso/permissionset/DeleteHandler.java [21:53]


    protected ProgressEvent<ResourceModel, CallbackContext> handleRequest(
        final AmazonWebServicesClientProxy proxy,
        final ResourceHandlerRequest<ResourceModel> request,
        final CallbackContext callbackContext,
        final ProxyClient<SsoAdminClient> proxyClient,
        final Logger logger) {

        this.logger = logger;

        if (!callbackContext.isHandlerInvoked()) {
            callbackContext.setHandlerInvoked(true);
            callbackContext.setRetryAttempts(RETRY_ATTEMPTS);
        }

        return ProgressEvent.progress(request.getDesiredResourceState(), callbackContext)
            .then(progress ->
                proxy.initiate("sso::delete-permissionset", proxyClient, progress.getResourceModel(), progress.getCallbackContext())
                    .translateToServiceRequest(Translator::translateToDeleteRequest)
                    .makeServiceCall((deleteRequest, client) -> proxy.injectCredentialsAndInvokeV2(deleteRequest, client.client()::deletePermissionSet))
                    .handleError((deleteRequest, exception, client, model, context) -> {
                        if (exception instanceof ResourceNotFoundException) {
                            return ProgressEvent.defaultFailureHandler(exception, HandlerErrorCode.NotFound);
                        } else if (exception instanceof ThrottlingException || exception instanceof ConflictException || exception instanceof InternalServerException) {
                            if (context.getRetryAttempts() == RETRY_ATTEMPTS_ZERO) {
                                return ProgressEvent.defaultFailureHandler(exception, mapExceptionToHandlerCode(exception));
                            }
                            context.decrementRetryAttempts();
                            return ProgressEvent.defaultInProgressHandler(callbackContext, getRetryTime(exception), model);
                        }
                        return ProgressEvent.defaultFailureHandler(exception, HandlerErrorCode.GeneralServiceException);
                    })
                    .done((deleteRequest, result, client, model, context) -> ProgressEvent.defaultSuccessHandler(null)));
    }