package software.amazon.vpclattice.service; import software.amazon.awssdk.services.vpclattice.VpcLatticeClient; import software.amazon.cloudformation.proxy.AmazonWebServicesClientProxy; import software.amazon.cloudformation.proxy.Logger; import software.amazon.cloudformation.proxy.ProgressEvent; import software.amazon.cloudformation.proxy.ProxyClient; import software.amazon.cloudformation.proxy.ResourceHandlerRequest; import software.amazon.vpclattice.common.ExceptionHandler; import javax.annotation.Nonnull; public class DeleteHandler extends BaseHandlerStd { @Override protected ProgressEvent handleRequest( @Nonnull final AmazonWebServicesClientProxy proxy, @Nonnull final ResourceHandlerRequest request, @Nonnull final CallbackContext callbackContext, @Nonnull final ProxyClient proxyClient, @Nonnull final Logger logger) { return ProgressEvent.progress(request.getDesiredResourceState(), callbackContext) .then((progress) -> this.deleteService(progress, proxy, proxyClient)); } private ProgressEvent deleteService( @Nonnull final ProgressEvent progress, @Nonnull final AmazonWebServicesClientProxy proxy, @Nonnull final ProxyClient proxyClient) { return proxy.initiate( "AWS::VpcLattice::Service::DeleteService", proxyClient, progress.getResourceModel(), progress.getCallbackContext() ) .translateToServiceRequest(Translator::createDeleteServiceRequest) .makeServiceCall((deleteServiceRequest, client) -> client.injectCredentialsAndInvokeV2(deleteServiceRequest, client.client()::deleteService)) .stabilize((_request, _response, client, model, _context) -> this.isServiceDeleted(client, model)) .handleError(ExceptionHandler::handleError) .done((_response) -> ProgressEvent.defaultSuccessHandler(null)); } }