/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 * 
 *  http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
/*
 * Do not modify this file. This file is generated from the iot-jobs-data-2017-09-29.normal.json service model.
 */
using System;
using System.Runtime.ExceptionServices;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Net;
using Amazon.IoTJobsDataPlane.Model;
using Amazon.IoTJobsDataPlane.Model.Internal.MarshallTransformations;
using Amazon.IoTJobsDataPlane.Internal;
using Amazon.Runtime;
using Amazon.Runtime.Internal;
using Amazon.Runtime.Internal.Auth;
using Amazon.Runtime.Internal.Transform;
namespace Amazon.IoTJobsDataPlane
{
    /// 
    /// Implementation for accessing IoTJobsDataPlane
    ///
    /// AWS IoT Jobs is a service that allows you to define a set of jobs — remote operations
    /// that are sent to and executed on one or more devices connected to AWS IoT. For example,
    /// you can define a job that instructs a set of devices to download and install application
    /// or firmware updates, reboot, rotate certificates, or perform remote troubleshooting
    /// operations.
    /// 
    ///  
    /// 
    ///  To create a job, you make a job document which is a description of the remote operations
    /// to be performed, and you specify a list of targets that should perform the operations.
    /// The targets can be individual things, thing groups or both.
    /// 
    ///  
    /// 
    ///  AWS IoT Jobs sends a message to inform the targets that a job is available. The target
    /// starts the execution of the job by downloading the job document, performing the operations
    /// it specifies, and reporting its progress to AWS IoT. The Jobs service provides commands
    /// to track the progress of a job on a specific target and for all the targets of the
    /// job
    /// 
    /// 
    public partial class AmazonIoTJobsDataPlaneClient : AmazonServiceClient, IAmazonIoTJobsDataPlane
    {
        private static IServiceMetadata serviceMetadata = new AmazonIoTJobsDataPlaneMetadata();
        
        #region Overrides
        /// 
        /// Creates the signer for the service.
        /// 
        protected override AbstractAWSSigner CreateSigner()
        {
            return new AWS4Signer();
        } 
        /// 
        /// Customizes the runtime pipeline.
        /// 
        /// Runtime pipeline for the current client.
        protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline)
        {
            pipeline.RemoveHandler();
            pipeline.AddHandlerAfter(new AmazonIoTJobsDataPlaneEndpointResolver());
        }
        /// 
        /// Capture metadata for the service.
        /// 
        protected override IServiceMetadata ServiceMetadata
        {
            get
            {
                return serviceMetadata;
            }
        }
        #endregion
        #region Dispose
        /// 
        /// Disposes the service client.
        /// 
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
        }
        #endregion
        #region  DescribeJobExecution
        internal virtual DescribeJobExecutionResponse DescribeJobExecution(DescribeJobExecutionRequest request)
        {
            var options = new InvokeOptions();
            options.RequestMarshaller = DescribeJobExecutionRequestMarshaller.Instance;
            options.ResponseUnmarshaller = DescribeJobExecutionResponseUnmarshaller.Instance;
            return Invoke(request, options);
        }
        /// 
        /// Gets details of a job execution.
        /// 
        /// Container for the necessary parameters to execute the DescribeJobExecution service method.
        /// 
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// 
        /// 
        /// The response from the DescribeJobExecution service method, as returned by IoTJobsDataPlane.
        /// 
        /// The certificate is invalid.
        /// 
        /// 
        /// The contents of the request were invalid. For example, this code is returned when
        /// an UpdateJobExecution request contains invalid status details. The message contains
        /// details about the error.
        /// 
        /// 
        /// The specified resource does not exist.
        /// 
        /// 
        /// The service is temporarily unavailable.
        /// 
        /// 
        /// The job is in a terminal state.
        /// 
        /// 
        /// The rate exceeds the limit.
        /// 
        /// REST API Reference for DescribeJobExecution Operation
        public virtual Task DescribeJobExecutionAsync(DescribeJobExecutionRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();
            options.RequestMarshaller = DescribeJobExecutionRequestMarshaller.Instance;
            options.ResponseUnmarshaller = DescribeJobExecutionResponseUnmarshaller.Instance;
            return InvokeAsync(request, options, cancellationToken);
        }
        #endregion
        
        #region  GetPendingJobExecutions
        internal virtual GetPendingJobExecutionsResponse GetPendingJobExecutions(GetPendingJobExecutionsRequest request)
        {
            var options = new InvokeOptions();
            options.RequestMarshaller = GetPendingJobExecutionsRequestMarshaller.Instance;
            options.ResponseUnmarshaller = GetPendingJobExecutionsResponseUnmarshaller.Instance;
            return Invoke(request, options);
        }
        /// 
        /// Gets the list of all jobs for a thing that are not in a terminal status.
        /// 
        /// Container for the necessary parameters to execute the GetPendingJobExecutions service method.
        /// 
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// 
        /// 
        /// The response from the GetPendingJobExecutions service method, as returned by IoTJobsDataPlane.
        /// 
        /// The certificate is invalid.
        /// 
        /// 
        /// The contents of the request were invalid. For example, this code is returned when
        /// an UpdateJobExecution request contains invalid status details. The message contains
        /// details about the error.
        /// 
        /// 
        /// The specified resource does not exist.
        /// 
        /// 
        /// The service is temporarily unavailable.
        /// 
        /// 
        /// The rate exceeds the limit.
        /// 
        /// REST API Reference for GetPendingJobExecutions Operation
        public virtual Task GetPendingJobExecutionsAsync(GetPendingJobExecutionsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();
            options.RequestMarshaller = GetPendingJobExecutionsRequestMarshaller.Instance;
            options.ResponseUnmarshaller = GetPendingJobExecutionsResponseUnmarshaller.Instance;
            return InvokeAsync(request, options, cancellationToken);
        }
        #endregion
        
        #region  StartNextPendingJobExecution
        internal virtual StartNextPendingJobExecutionResponse StartNextPendingJobExecution(StartNextPendingJobExecutionRequest request)
        {
            var options = new InvokeOptions();
            options.RequestMarshaller = StartNextPendingJobExecutionRequestMarshaller.Instance;
            options.ResponseUnmarshaller = StartNextPendingJobExecutionResponseUnmarshaller.Instance;
            return Invoke(request, options);
        }
        /// 
        /// Gets and starts the next pending (status IN_PROGRESS or QUEUED) job execution for
        /// a thing.
        /// 
        /// Container for the necessary parameters to execute the StartNextPendingJobExecution service method.
        /// 
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// 
        /// 
        /// The response from the StartNextPendingJobExecution service method, as returned by IoTJobsDataPlane.
        /// 
        /// The certificate is invalid.
        /// 
        /// 
        /// The contents of the request were invalid. For example, this code is returned when
        /// an UpdateJobExecution request contains invalid status details. The message contains
        /// details about the error.
        /// 
        /// 
        /// The specified resource does not exist.
        /// 
        /// 
        /// The service is temporarily unavailable.
        /// 
        /// 
        /// The rate exceeds the limit.
        /// 
        /// REST API Reference for StartNextPendingJobExecution Operation
        public virtual Task StartNextPendingJobExecutionAsync(StartNextPendingJobExecutionRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();
            options.RequestMarshaller = StartNextPendingJobExecutionRequestMarshaller.Instance;
            options.ResponseUnmarshaller = StartNextPendingJobExecutionResponseUnmarshaller.Instance;
            return InvokeAsync(request, options, cancellationToken);
        }
        #endregion
        
        #region  UpdateJobExecution
        internal virtual UpdateJobExecutionResponse UpdateJobExecution(UpdateJobExecutionRequest request)
        {
            var options = new InvokeOptions();
            options.RequestMarshaller = UpdateJobExecutionRequestMarshaller.Instance;
            options.ResponseUnmarshaller = UpdateJobExecutionResponseUnmarshaller.Instance;
            return Invoke(request, options);
        }
        /// 
        /// Updates the status of a job execution.
        /// 
        /// Container for the necessary parameters to execute the UpdateJobExecution service method.
        /// 
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// 
        /// 
        /// The response from the UpdateJobExecution service method, as returned by IoTJobsDataPlane.
        /// 
        /// The certificate is invalid.
        /// 
        /// 
        /// The contents of the request were invalid. For example, this code is returned when
        /// an UpdateJobExecution request contains invalid status details. The message contains
        /// details about the error.
        /// 
        /// 
        /// An update attempted to change the job execution to a state that is invalid because
        /// of the job execution's current state (for example, an attempt to change a request
        /// in state SUCCESS to state IN_PROGRESS). In this case, the body of the error message
        /// also contains the executionState field.
        /// 
        /// 
        /// The specified resource does not exist.
        /// 
        /// 
        /// The service is temporarily unavailable.
        /// 
        /// 
        /// The rate exceeds the limit.
        /// 
        /// REST API Reference for UpdateJobExecution Operation
        public virtual Task UpdateJobExecutionAsync(UpdateJobExecutionRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();
            options.RequestMarshaller = UpdateJobExecutionRequestMarshaller.Instance;
            options.ResponseUnmarshaller = UpdateJobExecutionResponseUnmarshaller.Instance;
            return InvokeAsync(request, options, cancellationToken);
        }
        #endregion
        
    }
}