/******************************************************************************* * Copyright 2012-2019 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. * ***************************************************************************** * * AWS Tools for Windows (TM) PowerShell (TM) * */ using System; using System.Collections.Generic; using System.Linq; using System.Management.Automation; using System.Text; using Amazon.PowerShell.Common; using Amazon.Runtime; using Amazon.IoT; using Amazon.IoT.Model; namespace Amazon.PowerShell.Cmdlets.IOT { /// /// Updates supported fields of the specified job. /// /// /// /// Requires permission to access the UpdateJob /// action. /// /// [Cmdlet("Update", "IOTJob", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)] [OutputType("None")] [AWSCmdlet("Calls the AWS IoT UpdateJob API operation.", Operation = new[] {"UpdateJob"}, SelectReturnType = typeof(Amazon.IoT.Model.UpdateJobResponse))] [AWSCmdletOutput("None or Amazon.IoT.Model.UpdateJobResponse", "This cmdlet does not generate any output." + "The service response (type Amazon.IoT.Model.UpdateJobResponse) can be referenced from properties attached to the cmdlet entry in the $AWSHistory stack." )] public partial class UpdateIOTJobCmdlet : AmazonIoTClientCmdlet, IExecutor { #region Parameter AbortConfig_CriteriaList /// /// /// The list of criteria that determine when and how to abort the job. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public Amazon.IoT.Model.AbortCriteria[] AbortConfig_CriteriaList { get; set; } #endregion #region Parameter JobExecutionsRetryConfig_CriteriaList /// /// /// The list of criteria that determines how many retries are allowed for each failure /// type for a job. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public Amazon.IoT.Model.RetryCriteria[] JobExecutionsRetryConfig_CriteriaList { get; set; } #endregion #region Parameter Description /// /// /// A short text description of the job. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String Description { get; set; } #endregion #region Parameter PresignedUrlConfig_ExpiresInSec /// /// /// How long (in seconds) pre-signed URLs are valid. Valid values are 60 - 3600, the default /// value is 3600 seconds. Pre-signed URLs are generated when Jobs receives an MQTT request /// for the job document. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Int64? PresignedUrlConfig_ExpiresInSec { get; set; } #endregion #region Parameter JobExecutionsRolloutConfig_ExponentialRate /// /// /// The rate of increase for a job rollout. This parameter allows you to define an exponential /// rate for a job rollout. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public Amazon.IoT.Model.ExponentialRolloutRate JobExecutionsRolloutConfig_ExponentialRate { get; set; } #endregion #region Parameter TimeoutConfig_InProgressTimeoutInMinute /// /// /// Specifies the amount of time, in minutes, this device has to finish execution of this /// job. The timeout interval can be anywhere between 1 minute and 7 days (1 to 10080 /// minutes). The in progress timer can't be updated and will apply to all job executions /// for the job. Whenever a job execution remains in the IN_PROGRESS status for longer /// than this interval, the job execution will fail and switch to the terminal TIMED_OUT /// status. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("TimeoutConfig_InProgressTimeoutInMinutes")] public System.Int64? TimeoutConfig_InProgressTimeoutInMinute { get; set; } #endregion #region Parameter JobId /// /// /// The ID of the job to be updated. /// /// #if !MODULAR [System.Management.Automation.Parameter(Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true)] #else [System.Management.Automation.Parameter(Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true, Mandatory = true)] [System.Management.Automation.AllowEmptyString] [System.Management.Automation.AllowNull] #endif [Amazon.PowerShell.Common.AWSRequiredParameter] public System.String JobId { get; set; } #endregion #region Parameter JobExecutionsRolloutConfig_MaximumPerMinute /// /// /// The maximum number of things that will be notified of a pending job, per minute. This /// parameter allows you to create a staged rollout. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.Int32? JobExecutionsRolloutConfig_MaximumPerMinute { get; set; } #endregion #region Parameter NamespaceId /// /// /// The namespace used to indicate that a job is a customer-managed job.When you specify a value for this parameter, Amazon Web Services IoT Core sends jobs /// notifications to MQTT topics that contain the value in the following format.$aws/things/THING_NAME/jobs/JOB_ID/notify-namespace-NAMESPACE_ID/The namespaceId feature is in public preview. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String NamespaceId { get; set; } #endregion #region Parameter PresignedUrlConfig_RoleArn /// /// /// The ARN of an IAM role that grants permission to download files from the S3 bucket /// where the job data/updates are stored. The role must also grant permission for IoT /// to download the files.For information about addressing the confused deputy problem, see cross-service /// confused deputy prevention in the Amazon Web Services IoT Core developer guide. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String PresignedUrlConfig_RoleArn { get; set; } #endregion #region Parameter Select /// /// Use the -Select parameter to control the cmdlet output. The cmdlet doesn't have a return value by default. /// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.IoT.Model.UpdateJobResponse). /// Specifying -Select '^ParameterName' will result in the cmdlet returning the selected cmdlet parameter value. /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public string Select { get; set; } = "*"; #endregion #region Parameter PassThru /// /// Changes the cmdlet behavior to return the value passed to the JobId parameter. /// The -PassThru parameter is deprecated, use -Select '^JobId' instead. This parameter will be removed in a future version. /// [System.Obsolete("The -PassThru parameter is deprecated, use -Select '^JobId' instead. This parameter will be removed in a future version.")] [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public SwitchParameter PassThru { get; set; } #endregion #region Parameter Force /// /// This parameter overrides confirmation prompts to force /// the cmdlet to continue its operation. This parameter should always /// be used with caution. /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public SwitchParameter Force { get; set; } #endregion protected override void ProcessRecord() { this._AWSSignerType = "v4"; base.ProcessRecord(); var resourceIdentifiersText = FormatParameterValuesForConfirmationMsg(nameof(this.JobId), MyInvocation.BoundParameters); if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Update-IOTJob (UpdateJob)")) { return; } var context = new CmdletContext(); // allow for manipulation of parameters prior to loading into context PreExecutionContextLoad(context); #pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute if (ParameterWasBound(nameof(this.Select))) { context.Select = CreateSelectDelegate(Select) ?? throw new System.ArgumentException("Invalid value for -Select parameter.", nameof(this.Select)); if (this.PassThru.IsPresent) { throw new System.ArgumentException("-PassThru cannot be used when -Select is specified.", nameof(this.Select)); } } else if (this.PassThru.IsPresent) { context.Select = (response, cmdlet) => this.JobId; } #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute if (this.AbortConfig_CriteriaList != null) { context.AbortConfig_CriteriaList = new List(this.AbortConfig_CriteriaList); } context.Description = this.Description; if (this.JobExecutionsRetryConfig_CriteriaList != null) { context.JobExecutionsRetryConfig_CriteriaList = new List(this.JobExecutionsRetryConfig_CriteriaList); } context.JobExecutionsRolloutConfig_ExponentialRate = this.JobExecutionsRolloutConfig_ExponentialRate; context.JobExecutionsRolloutConfig_MaximumPerMinute = this.JobExecutionsRolloutConfig_MaximumPerMinute; context.JobId = this.JobId; #if MODULAR if (this.JobId == null && ParameterWasBound(nameof(this.JobId))) { WriteWarning("You are passing $null as a value for parameter JobId which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues."); } #endif context.NamespaceId = this.NamespaceId; context.PresignedUrlConfig_ExpiresInSec = this.PresignedUrlConfig_ExpiresInSec; context.PresignedUrlConfig_RoleArn = this.PresignedUrlConfig_RoleArn; context.TimeoutConfig_InProgressTimeoutInMinute = this.TimeoutConfig_InProgressTimeoutInMinute; // allow further manipulation of loaded context prior to processing PostExecutionContextLoad(context); var output = Execute(context) as CmdletOutput; ProcessOutput(output); } #region IExecutor Members public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.IoT.Model.UpdateJobRequest(); // populate AbortConfig var requestAbortConfigIsNull = true; request.AbortConfig = new Amazon.IoT.Model.AbortConfig(); List requestAbortConfig_abortConfig_CriteriaList = null; if (cmdletContext.AbortConfig_CriteriaList != null) { requestAbortConfig_abortConfig_CriteriaList = cmdletContext.AbortConfig_CriteriaList; } if (requestAbortConfig_abortConfig_CriteriaList != null) { request.AbortConfig.CriteriaList = requestAbortConfig_abortConfig_CriteriaList; requestAbortConfigIsNull = false; } // determine if request.AbortConfig should be set to null if (requestAbortConfigIsNull) { request.AbortConfig = null; } if (cmdletContext.Description != null) { request.Description = cmdletContext.Description; } // populate JobExecutionsRetryConfig var requestJobExecutionsRetryConfigIsNull = true; request.JobExecutionsRetryConfig = new Amazon.IoT.Model.JobExecutionsRetryConfig(); List requestJobExecutionsRetryConfig_jobExecutionsRetryConfig_CriteriaList = null; if (cmdletContext.JobExecutionsRetryConfig_CriteriaList != null) { requestJobExecutionsRetryConfig_jobExecutionsRetryConfig_CriteriaList = cmdletContext.JobExecutionsRetryConfig_CriteriaList; } if (requestJobExecutionsRetryConfig_jobExecutionsRetryConfig_CriteriaList != null) { request.JobExecutionsRetryConfig.CriteriaList = requestJobExecutionsRetryConfig_jobExecutionsRetryConfig_CriteriaList; requestJobExecutionsRetryConfigIsNull = false; } // determine if request.JobExecutionsRetryConfig should be set to null if (requestJobExecutionsRetryConfigIsNull) { request.JobExecutionsRetryConfig = null; } // populate JobExecutionsRolloutConfig var requestJobExecutionsRolloutConfigIsNull = true; request.JobExecutionsRolloutConfig = new Amazon.IoT.Model.JobExecutionsRolloutConfig(); Amazon.IoT.Model.ExponentialRolloutRate requestJobExecutionsRolloutConfig_jobExecutionsRolloutConfig_ExponentialRate = null; if (cmdletContext.JobExecutionsRolloutConfig_ExponentialRate != null) { requestJobExecutionsRolloutConfig_jobExecutionsRolloutConfig_ExponentialRate = cmdletContext.JobExecutionsRolloutConfig_ExponentialRate; } if (requestJobExecutionsRolloutConfig_jobExecutionsRolloutConfig_ExponentialRate != null) { request.JobExecutionsRolloutConfig.ExponentialRate = requestJobExecutionsRolloutConfig_jobExecutionsRolloutConfig_ExponentialRate; requestJobExecutionsRolloutConfigIsNull = false; } System.Int32? requestJobExecutionsRolloutConfig_jobExecutionsRolloutConfig_MaximumPerMinute = null; if (cmdletContext.JobExecutionsRolloutConfig_MaximumPerMinute != null) { requestJobExecutionsRolloutConfig_jobExecutionsRolloutConfig_MaximumPerMinute = cmdletContext.JobExecutionsRolloutConfig_MaximumPerMinute.Value; } if (requestJobExecutionsRolloutConfig_jobExecutionsRolloutConfig_MaximumPerMinute != null) { request.JobExecutionsRolloutConfig.MaximumPerMinute = requestJobExecutionsRolloutConfig_jobExecutionsRolloutConfig_MaximumPerMinute.Value; requestJobExecutionsRolloutConfigIsNull = false; } // determine if request.JobExecutionsRolloutConfig should be set to null if (requestJobExecutionsRolloutConfigIsNull) { request.JobExecutionsRolloutConfig = null; } if (cmdletContext.JobId != null) { request.JobId = cmdletContext.JobId; } if (cmdletContext.NamespaceId != null) { request.NamespaceId = cmdletContext.NamespaceId; } // populate PresignedUrlConfig var requestPresignedUrlConfigIsNull = true; request.PresignedUrlConfig = new Amazon.IoT.Model.PresignedUrlConfig(); System.Int64? requestPresignedUrlConfig_presignedUrlConfig_ExpiresInSec = null; if (cmdletContext.PresignedUrlConfig_ExpiresInSec != null) { requestPresignedUrlConfig_presignedUrlConfig_ExpiresInSec = cmdletContext.PresignedUrlConfig_ExpiresInSec.Value; } if (requestPresignedUrlConfig_presignedUrlConfig_ExpiresInSec != null) { request.PresignedUrlConfig.ExpiresInSec = requestPresignedUrlConfig_presignedUrlConfig_ExpiresInSec.Value; requestPresignedUrlConfigIsNull = false; } System.String requestPresignedUrlConfig_presignedUrlConfig_RoleArn = null; if (cmdletContext.PresignedUrlConfig_RoleArn != null) { requestPresignedUrlConfig_presignedUrlConfig_RoleArn = cmdletContext.PresignedUrlConfig_RoleArn; } if (requestPresignedUrlConfig_presignedUrlConfig_RoleArn != null) { request.PresignedUrlConfig.RoleArn = requestPresignedUrlConfig_presignedUrlConfig_RoleArn; requestPresignedUrlConfigIsNull = false; } // determine if request.PresignedUrlConfig should be set to null if (requestPresignedUrlConfigIsNull) { request.PresignedUrlConfig = null; } // populate TimeoutConfig var requestTimeoutConfigIsNull = true; request.TimeoutConfig = new Amazon.IoT.Model.TimeoutConfig(); System.Int64? requestTimeoutConfig_timeoutConfig_InProgressTimeoutInMinute = null; if (cmdletContext.TimeoutConfig_InProgressTimeoutInMinute != null) { requestTimeoutConfig_timeoutConfig_InProgressTimeoutInMinute = cmdletContext.TimeoutConfig_InProgressTimeoutInMinute.Value; } if (requestTimeoutConfig_timeoutConfig_InProgressTimeoutInMinute != null) { request.TimeoutConfig.InProgressTimeoutInMinutes = requestTimeoutConfig_timeoutConfig_InProgressTimeoutInMinute.Value; requestTimeoutConfigIsNull = false; } // determine if request.TimeoutConfig should be set to null if (requestTimeoutConfigIsNull) { request.TimeoutConfig = null; } CmdletOutput output; // issue call var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint); try { var response = CallAWSServiceOperation(client, request); object pipelineOutput = null; pipelineOutput = cmdletContext.Select(response, this); output = new CmdletOutput { PipelineOutput = pipelineOutput, ServiceResponse = response }; } catch (Exception e) { output = new CmdletOutput { ErrorResponse = e }; } return output; } public ExecutorContext CreateContext() { return new CmdletContext(); } #endregion #region AWS Service Operation Call private Amazon.IoT.Model.UpdateJobResponse CallAWSServiceOperation(IAmazonIoT client, Amazon.IoT.Model.UpdateJobRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS IoT", "UpdateJob"); try { #if DESKTOP return client.UpdateJob(request); #elif CORECLR return client.UpdateJobAsync(request).GetAwaiter().GetResult(); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } } #endregion internal partial class CmdletContext : ExecutorContext { public List AbortConfig_CriteriaList { get; set; } public System.String Description { get; set; } public List JobExecutionsRetryConfig_CriteriaList { get; set; } public Amazon.IoT.Model.ExponentialRolloutRate JobExecutionsRolloutConfig_ExponentialRate { get; set; } public System.Int32? JobExecutionsRolloutConfig_MaximumPerMinute { get; set; } public System.String JobId { get; set; } public System.String NamespaceId { get; set; } public System.Int64? PresignedUrlConfig_ExpiresInSec { get; set; } public System.String PresignedUrlConfig_RoleArn { get; set; } public System.Int64? TimeoutConfig_InProgressTimeoutInMinute { get; set; } public System.Func Select { get; set; } = (response, cmdlet) => null; } } }