class AWSAppAutoScalingClient implements AppAutoScalingClient {

    @Override
    public Completable deleteScalingPolicy(String policyRefId, String jobId) {
        DeleteScalingPolicyRequest deleteScalingPolicyRequest = new DeleteScalingPolicyRequest();
        deleteScalingPolicyRequest.setResourceId(
                AWSAppAutoScalingUtil.buildGatewayResourceId(jobId,
                        awsAppScalingConfig.getAWSGatewayEndpointPrefix(),
                        awsAppScalingConfig.getRegion(),
                        awsAppScalingConfig.getAWSGatewayEndpointTargetStage()));
        deleteScalingPolicyRequest.setServiceNamespace(SERVICE_NAMESPACE);
        deleteScalingPolicyRequest.setScalableDimension(SCALABLE_DIMENSION);
        deleteScalingPolicyRequest.setPolicyName(buildScalingPolicyName(policyRefId, jobId));

        return RetryWrapper.wrapWithExponentialRetry(String.format("deleteScalingPolicy %s for job %s", policyRefId, jobId),
                Observable.create(emitter -> awsAppAutoScalingClientAsync.deleteScalingPolicyAsync(deleteScalingPolicyRequest, new AsyncHandler<DeleteScalingPolicyRequest, DeleteScalingPolicyResult>() {
                    @Override
                    public void onError(Exception exception) {
                        if (exception instanceof ObjectNotFoundException) {
                            logger.info("Scaling policy does not exist anymore for job/policyRefId {}/{}", jobId, policyRefId);
                            emitter.onCompleted();
                        } else {
                            logger.error("Delete scaling policy exception {} - {}", jobId, exception.getMessage());
                            awsAppAutoScalingMetrics.registerAwsDeletePolicyError(exception);
                            emitter.onError(AutoScalePolicyException.errorDeletingPolicy(policyRefId, exception.getMessage()));
                        }
                    }

                    @Override
                    public void onSuccess(DeleteScalingPolicyRequest request, DeleteScalingPolicyResult deleteScalingPolicyResult) {
                        int httpStatusCode = deleteScalingPolicyResult.getSdkHttpMetadata().getHttpStatusCode();
                        logger.info("Deleted scaling policy for job/policyRefId {}/{}, status - {}", jobId, policyRefId, httpStatusCode);
                        awsAppAutoScalingMetrics.registerAwsDeletePolicySuccess();
                        emitter.onCompleted();

                    }
                }), Emitter.BackpressureMode.NONE)).toCompletable();
    }

    @Inject public  AWSAppAutoScalingClient(AWSCredentialsProvider awsCredentialsProvider,
                                   AWSAppScalingConfig awsAppScalingConfig,
                                   Registry registry);
    @VisibleForTesting  AWSAppAutoScalingClient(AWSApplicationAutoScalingAsync awsAppAutoScalingClientAsync, AWSAppScalingConfig awsAppScalingConfig, Registry registry);

}