@SdkInternalApi
    final CancelTaskResult executeCancelTask(CancelTaskRequest cancelTaskRequest) {

        ExecutionContext executionContext = createExecutionContext(cancelTaskRequest);
        AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
        awsRequestMetrics.startEvent(Field.ClientExecuteTime);
        Request<CancelTaskRequest> request = null;
        Response<CancelTaskResult> response = null;

        try {
            awsRequestMetrics.startEvent(Field.RequestMarshallTime);
            try {
                request = new CancelTaskRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(cancelTaskRequest));
                // 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, "Snow Device Management");
                request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "CancelTask");
                request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);

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

            HttpResponseHandler<AmazonWebServiceResponse<CancelTaskResult>> responseHandler = protocolFactory.createResponseHandler(new JsonOperationMetadata()
                    .withPayloadJson(true).withHasStreamingSuccessResponse(false), new CancelTaskResultJsonUnmarshaller());
            response = invoke(request, responseHandler, executionContext);

            return response.getAwsResponse();

        } finally {

            endClientExecution(awsRequestMetrics, request, response);
        }
    }
<p>
Sends a cancel request for a specified task. You can cancel a task only if it's still in a <code>QUEUED</code>
state. Tasks that are already running can't be cancelled.
</p>
<note>
<p>
A task might still run if it's processed from the queue before the <code>CancelTask</code> operation changes the
task's state.
</p>
</note>

@param cancelTaskRequest
@return Result of the CancelTask operation returned by the service.
@throws ThrottlingException
        The request was denied due to request throttling.
@throws InternalServerException
        An unexpected error occurred while processing the request.
@throws ResourceNotFoundException
        The request references a resource that doesn't exist.
@throws ValidationException
        The input fails to satisfy the constraints specified by an Amazon Web Services service.
@throws AccessDeniedException
        You don't have sufficient access to perform this action.
@sample AWSSnowDeviceManagement.CancelTask
@see <a href="http://docs.aws.amazon.com/goto/WebAPI/snow-device-management-2021-08-04/CancelTask"
     target="_top">AWS API Documentation</a>
aws-java-sdk-snowdevicemanagement/src/main/java/com/amazonaws/services/snowdevicemanagement/AWSSnowDeviceManagementClient.java