@SdkInternalApi
    final DeregisterImageResult executeDeregisterImage(DeregisterImageRequest deregisterImageRequest) {

        ExecutionContext executionContext = createExecutionContext(deregisterImageRequest);
        AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
        awsRequestMetrics.startEvent(Field.ClientExecuteTime);
        Request<DeregisterImageRequest> request = null;
        Response<DeregisterImageResult> response = null;

        try {
            awsRequestMetrics.startEvent(Field.RequestMarshallTime);
            try {
                request = new DeregisterImageRequestMarshaller().marshall(super.beforeMarshalling(deregisterImageRequest));
                // Binds the request metrics to the current request.
                request.setAWSRequestMetrics(awsRequestMetrics);
                request.addHandlerContext(HandlerContextKey.CLIENT_ENDPOINT, endpoint);
                request.addHandlerContext(HandlerContextKey.ENDPOINT_OVERRIDDEN, isEndpointOverridden());
                request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
                request.addHandlerContext(HandlerContextKey.SERVICE_ID, "EC2");
                request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "DeregisterImage");
                request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);

            } finally {
                awsRequestMetrics.endEvent(Field.RequestMarshallTime);
            }

            StaxResponseHandler<DeregisterImageResult> responseHandler = new StaxResponseHandler<DeregisterImageResult>(
                    new DeregisterImageResultStaxUnmarshaller());

            response = invoke(request, responseHandler, executionContext);

            return response.getAwsResponse();

        } finally {

            endClientExecution(awsRequestMetrics, request, response);
        }
    }
<p>
Deregisters the specified AMI. After you deregister an AMI, it can't be used to launch new instances.
</p>
<p>
If you deregister an AMI that matches a Recycle Bin retention rule, the AMI is retained in the Recycle Bin for
the specified retention period. For more information, see <a
href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recycle-bin.html">Recycle Bin</a> in the <i>Amazon EC2
User Guide</i>.
</p>
<p>
When you deregister an AMI, it doesn't affect any instances that you've already launched from the AMI. You'll
continue to incur usage costs for those instances until you terminate them.
</p>
<p>
When you deregister an Amazon EBS-backed AMI, it doesn't affect the snapshot that was created for the root volume
of the instance during the AMI creation process. When you deregister an instance store-backed AMI, it doesn't
affect the files that you uploaded to Amazon S3 when you created the AMI.
</p>

@param deregisterImageRequest
       Contains the parameters for DeregisterImage.
@return Result of the DeregisterImage operation returned by the service.
@sample AmazonEC2.DeregisterImage
@see <a href="http://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15/DeregisterImage" target="_top">AWS API
     Documentation</a>
aws-java-sdk-ec2/src/main/java/com/amazonaws/services/ec2/AmazonEC2Client.java