/******************************************************************************* * 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 the definition for the specified mitigation action. /// /// /// /// Requires permission to access the UpdateMitigationAction /// action. /// /// [Cmdlet("Update", "IOTMitigationAction", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)] [OutputType("Amazon.IoT.Model.UpdateMitigationActionResponse")] [AWSCmdlet("Calls the AWS IoT UpdateMitigationAction API operation.", Operation = new[] {"UpdateMitigationAction"}, SelectReturnType = typeof(Amazon.IoT.Model.UpdateMitigationActionResponse))] [AWSCmdletOutput("Amazon.IoT.Model.UpdateMitigationActionResponse", "This cmdlet returns an Amazon.IoT.Model.UpdateMitigationActionResponse object containing multiple properties. The object can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack." )] public partial class UpdateIOTMitigationActionCmdlet : AmazonIoTClientCmdlet, IExecutor { #region Parameter UpdateCACertificateParams_Action /// /// /// The action that you want to apply to the CA certificate. The only supported value /// is DEACTIVATE. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ActionParams_UpdateCACertificateParams_Action")] [AWSConstantClassSource("Amazon.IoT.CACertificateUpdateAction")] public Amazon.IoT.CACertificateUpdateAction UpdateCACertificateParams_Action { get; set; } #endregion #region Parameter UpdateDeviceCertificateParams_Action /// /// /// The action that you want to apply to the device certificate. The only supported value /// is DEACTIVATE. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ActionParams_UpdateDeviceCertificateParams_Action")] [AWSConstantClassSource("Amazon.IoT.DeviceCertificateUpdateAction")] public Amazon.IoT.DeviceCertificateUpdateAction UpdateDeviceCertificateParams_Action { get; set; } #endregion #region Parameter ActionName /// /// /// The friendly name for the mitigation action. You cannot change the name by using UpdateMitigationAction. /// Instead, you must delete and recreate the mitigation action with the new name. /// /// #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 ActionName { get; set; } #endregion #region Parameter EnableIoTLoggingParams_LogLevel /// /// /// Specifies the type of information to be logged. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ActionParams_EnableIoTLoggingParams_LogLevel")] [AWSConstantClassSource("Amazon.IoT.LogLevel")] public Amazon.IoT.LogLevel EnableIoTLoggingParams_LogLevel { get; set; } #endregion #region Parameter AddThingsToThingGroupParams_OverrideDynamicGroup /// /// /// Specifies if this mitigation action can move the things that triggered the mitigation /// action even if they are part of one or more dynamic thing groups. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ActionParams_AddThingsToThingGroupParams_OverrideDynamicGroups")] public System.Boolean? AddThingsToThingGroupParams_OverrideDynamicGroup { get; set; } #endregion #region Parameter RoleArn /// /// /// The ARN of the IAM role that is used to apply the mitigation action. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String RoleArn { get; set; } #endregion #region Parameter EnableIoTLoggingParams_RoleArnForLogging /// /// /// The Amazon Resource Name (ARN) of the IAM role used for logging. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ActionParams_EnableIoTLoggingParams_RoleArnForLogging")] public System.String EnableIoTLoggingParams_RoleArnForLogging { get; set; } #endregion #region Parameter ReplaceDefaultPolicyVersionParams_TemplateName /// /// /// The name of the template to be applied. The only supported value is BLANK_POLICY. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ActionParams_ReplaceDefaultPolicyVersionParams_TemplateName")] [AWSConstantClassSource("Amazon.IoT.PolicyTemplateName")] public Amazon.IoT.PolicyTemplateName ReplaceDefaultPolicyVersionParams_TemplateName { get; set; } #endregion #region Parameter AddThingsToThingGroupParams_ThingGroupName /// /// /// The list of groups to which you want to add the things that triggered the mitigation /// action. You can add a thing to a maximum of 10 groups, but you can't add a thing to /// more than one group in the same hierarchy. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ActionParams_AddThingsToThingGroupParams_ThingGroupNames")] public System.String[] AddThingsToThingGroupParams_ThingGroupName { get; set; } #endregion #region Parameter PublishFindingToSnsParams_TopicArn /// /// /// The ARN of the topic to which you want to publish the findings. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ActionParams_PublishFindingToSnsParams_TopicArn")] public System.String PublishFindingToSnsParams_TopicArn { get; set; } #endregion #region Parameter Select /// /// Use the -Select parameter to control the cmdlet output. The default value is '*'. /// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.IoT.Model.UpdateMitigationActionResponse). /// Specifying the name of a property of type Amazon.IoT.Model.UpdateMitigationActionResponse will result in that property being returned. /// 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 ActionName parameter. /// The -PassThru parameter is deprecated, use -Select '^ActionName' instead. This parameter will be removed in a future version. /// [System.Obsolete("The -PassThru parameter is deprecated, use -Select '^ActionName' 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.ActionName), MyInvocation.BoundParameters); if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Update-IOTMitigationAction (UpdateMitigationAction)")) { 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.ActionName; } #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute context.ActionName = this.ActionName; #if MODULAR if (this.ActionName == null && ParameterWasBound(nameof(this.ActionName))) { WriteWarning("You are passing $null as a value for parameter ActionName 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.AddThingsToThingGroupParams_OverrideDynamicGroup = this.AddThingsToThingGroupParams_OverrideDynamicGroup; if (this.AddThingsToThingGroupParams_ThingGroupName != null) { context.AddThingsToThingGroupParams_ThingGroupName = new List(this.AddThingsToThingGroupParams_ThingGroupName); } context.EnableIoTLoggingParams_LogLevel = this.EnableIoTLoggingParams_LogLevel; context.EnableIoTLoggingParams_RoleArnForLogging = this.EnableIoTLoggingParams_RoleArnForLogging; context.PublishFindingToSnsParams_TopicArn = this.PublishFindingToSnsParams_TopicArn; context.ReplaceDefaultPolicyVersionParams_TemplateName = this.ReplaceDefaultPolicyVersionParams_TemplateName; context.UpdateCACertificateParams_Action = this.UpdateCACertificateParams_Action; context.UpdateDeviceCertificateParams_Action = this.UpdateDeviceCertificateParams_Action; context.RoleArn = this.RoleArn; // 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.UpdateMitigationActionRequest(); if (cmdletContext.ActionName != null) { request.ActionName = cmdletContext.ActionName; } // populate ActionParams var requestActionParamsIsNull = true; request.ActionParams = new Amazon.IoT.Model.MitigationActionParams(); Amazon.IoT.Model.PublishFindingToSnsParams requestActionParams_actionParams_PublishFindingToSnsParams = null; // populate PublishFindingToSnsParams var requestActionParams_actionParams_PublishFindingToSnsParamsIsNull = true; requestActionParams_actionParams_PublishFindingToSnsParams = new Amazon.IoT.Model.PublishFindingToSnsParams(); System.String requestActionParams_actionParams_PublishFindingToSnsParams_publishFindingToSnsParams_TopicArn = null; if (cmdletContext.PublishFindingToSnsParams_TopicArn != null) { requestActionParams_actionParams_PublishFindingToSnsParams_publishFindingToSnsParams_TopicArn = cmdletContext.PublishFindingToSnsParams_TopicArn; } if (requestActionParams_actionParams_PublishFindingToSnsParams_publishFindingToSnsParams_TopicArn != null) { requestActionParams_actionParams_PublishFindingToSnsParams.TopicArn = requestActionParams_actionParams_PublishFindingToSnsParams_publishFindingToSnsParams_TopicArn; requestActionParams_actionParams_PublishFindingToSnsParamsIsNull = false; } // determine if requestActionParams_actionParams_PublishFindingToSnsParams should be set to null if (requestActionParams_actionParams_PublishFindingToSnsParamsIsNull) { requestActionParams_actionParams_PublishFindingToSnsParams = null; } if (requestActionParams_actionParams_PublishFindingToSnsParams != null) { request.ActionParams.PublishFindingToSnsParams = requestActionParams_actionParams_PublishFindingToSnsParams; requestActionParamsIsNull = false; } Amazon.IoT.Model.ReplaceDefaultPolicyVersionParams requestActionParams_actionParams_ReplaceDefaultPolicyVersionParams = null; // populate ReplaceDefaultPolicyVersionParams var requestActionParams_actionParams_ReplaceDefaultPolicyVersionParamsIsNull = true; requestActionParams_actionParams_ReplaceDefaultPolicyVersionParams = new Amazon.IoT.Model.ReplaceDefaultPolicyVersionParams(); Amazon.IoT.PolicyTemplateName requestActionParams_actionParams_ReplaceDefaultPolicyVersionParams_replaceDefaultPolicyVersionParams_TemplateName = null; if (cmdletContext.ReplaceDefaultPolicyVersionParams_TemplateName != null) { requestActionParams_actionParams_ReplaceDefaultPolicyVersionParams_replaceDefaultPolicyVersionParams_TemplateName = cmdletContext.ReplaceDefaultPolicyVersionParams_TemplateName; } if (requestActionParams_actionParams_ReplaceDefaultPolicyVersionParams_replaceDefaultPolicyVersionParams_TemplateName != null) { requestActionParams_actionParams_ReplaceDefaultPolicyVersionParams.TemplateName = requestActionParams_actionParams_ReplaceDefaultPolicyVersionParams_replaceDefaultPolicyVersionParams_TemplateName; requestActionParams_actionParams_ReplaceDefaultPolicyVersionParamsIsNull = false; } // determine if requestActionParams_actionParams_ReplaceDefaultPolicyVersionParams should be set to null if (requestActionParams_actionParams_ReplaceDefaultPolicyVersionParamsIsNull) { requestActionParams_actionParams_ReplaceDefaultPolicyVersionParams = null; } if (requestActionParams_actionParams_ReplaceDefaultPolicyVersionParams != null) { request.ActionParams.ReplaceDefaultPolicyVersionParams = requestActionParams_actionParams_ReplaceDefaultPolicyVersionParams; requestActionParamsIsNull = false; } Amazon.IoT.Model.UpdateCACertificateParams requestActionParams_actionParams_UpdateCACertificateParams = null; // populate UpdateCACertificateParams var requestActionParams_actionParams_UpdateCACertificateParamsIsNull = true; requestActionParams_actionParams_UpdateCACertificateParams = new Amazon.IoT.Model.UpdateCACertificateParams(); Amazon.IoT.CACertificateUpdateAction requestActionParams_actionParams_UpdateCACertificateParams_updateCACertificateParams_Action = null; if (cmdletContext.UpdateCACertificateParams_Action != null) { requestActionParams_actionParams_UpdateCACertificateParams_updateCACertificateParams_Action = cmdletContext.UpdateCACertificateParams_Action; } if (requestActionParams_actionParams_UpdateCACertificateParams_updateCACertificateParams_Action != null) { requestActionParams_actionParams_UpdateCACertificateParams.Action = requestActionParams_actionParams_UpdateCACertificateParams_updateCACertificateParams_Action; requestActionParams_actionParams_UpdateCACertificateParamsIsNull = false; } // determine if requestActionParams_actionParams_UpdateCACertificateParams should be set to null if (requestActionParams_actionParams_UpdateCACertificateParamsIsNull) { requestActionParams_actionParams_UpdateCACertificateParams = null; } if (requestActionParams_actionParams_UpdateCACertificateParams != null) { request.ActionParams.UpdateCACertificateParams = requestActionParams_actionParams_UpdateCACertificateParams; requestActionParamsIsNull = false; } Amazon.IoT.Model.UpdateDeviceCertificateParams requestActionParams_actionParams_UpdateDeviceCertificateParams = null; // populate UpdateDeviceCertificateParams var requestActionParams_actionParams_UpdateDeviceCertificateParamsIsNull = true; requestActionParams_actionParams_UpdateDeviceCertificateParams = new Amazon.IoT.Model.UpdateDeviceCertificateParams(); Amazon.IoT.DeviceCertificateUpdateAction requestActionParams_actionParams_UpdateDeviceCertificateParams_updateDeviceCertificateParams_Action = null; if (cmdletContext.UpdateDeviceCertificateParams_Action != null) { requestActionParams_actionParams_UpdateDeviceCertificateParams_updateDeviceCertificateParams_Action = cmdletContext.UpdateDeviceCertificateParams_Action; } if (requestActionParams_actionParams_UpdateDeviceCertificateParams_updateDeviceCertificateParams_Action != null) { requestActionParams_actionParams_UpdateDeviceCertificateParams.Action = requestActionParams_actionParams_UpdateDeviceCertificateParams_updateDeviceCertificateParams_Action; requestActionParams_actionParams_UpdateDeviceCertificateParamsIsNull = false; } // determine if requestActionParams_actionParams_UpdateDeviceCertificateParams should be set to null if (requestActionParams_actionParams_UpdateDeviceCertificateParamsIsNull) { requestActionParams_actionParams_UpdateDeviceCertificateParams = null; } if (requestActionParams_actionParams_UpdateDeviceCertificateParams != null) { request.ActionParams.UpdateDeviceCertificateParams = requestActionParams_actionParams_UpdateDeviceCertificateParams; requestActionParamsIsNull = false; } Amazon.IoT.Model.AddThingsToThingGroupParams requestActionParams_actionParams_AddThingsToThingGroupParams = null; // populate AddThingsToThingGroupParams var requestActionParams_actionParams_AddThingsToThingGroupParamsIsNull = true; requestActionParams_actionParams_AddThingsToThingGroupParams = new Amazon.IoT.Model.AddThingsToThingGroupParams(); System.Boolean? requestActionParams_actionParams_AddThingsToThingGroupParams_addThingsToThingGroupParams_OverrideDynamicGroup = null; if (cmdletContext.AddThingsToThingGroupParams_OverrideDynamicGroup != null) { requestActionParams_actionParams_AddThingsToThingGroupParams_addThingsToThingGroupParams_OverrideDynamicGroup = cmdletContext.AddThingsToThingGroupParams_OverrideDynamicGroup.Value; } if (requestActionParams_actionParams_AddThingsToThingGroupParams_addThingsToThingGroupParams_OverrideDynamicGroup != null) { requestActionParams_actionParams_AddThingsToThingGroupParams.OverrideDynamicGroups = requestActionParams_actionParams_AddThingsToThingGroupParams_addThingsToThingGroupParams_OverrideDynamicGroup.Value; requestActionParams_actionParams_AddThingsToThingGroupParamsIsNull = false; } List requestActionParams_actionParams_AddThingsToThingGroupParams_addThingsToThingGroupParams_ThingGroupName = null; if (cmdletContext.AddThingsToThingGroupParams_ThingGroupName != null) { requestActionParams_actionParams_AddThingsToThingGroupParams_addThingsToThingGroupParams_ThingGroupName = cmdletContext.AddThingsToThingGroupParams_ThingGroupName; } if (requestActionParams_actionParams_AddThingsToThingGroupParams_addThingsToThingGroupParams_ThingGroupName != null) { requestActionParams_actionParams_AddThingsToThingGroupParams.ThingGroupNames = requestActionParams_actionParams_AddThingsToThingGroupParams_addThingsToThingGroupParams_ThingGroupName; requestActionParams_actionParams_AddThingsToThingGroupParamsIsNull = false; } // determine if requestActionParams_actionParams_AddThingsToThingGroupParams should be set to null if (requestActionParams_actionParams_AddThingsToThingGroupParamsIsNull) { requestActionParams_actionParams_AddThingsToThingGroupParams = null; } if (requestActionParams_actionParams_AddThingsToThingGroupParams != null) { request.ActionParams.AddThingsToThingGroupParams = requestActionParams_actionParams_AddThingsToThingGroupParams; requestActionParamsIsNull = false; } Amazon.IoT.Model.EnableIoTLoggingParams requestActionParams_actionParams_EnableIoTLoggingParams = null; // populate EnableIoTLoggingParams var requestActionParams_actionParams_EnableIoTLoggingParamsIsNull = true; requestActionParams_actionParams_EnableIoTLoggingParams = new Amazon.IoT.Model.EnableIoTLoggingParams(); Amazon.IoT.LogLevel requestActionParams_actionParams_EnableIoTLoggingParams_enableIoTLoggingParams_LogLevel = null; if (cmdletContext.EnableIoTLoggingParams_LogLevel != null) { requestActionParams_actionParams_EnableIoTLoggingParams_enableIoTLoggingParams_LogLevel = cmdletContext.EnableIoTLoggingParams_LogLevel; } if (requestActionParams_actionParams_EnableIoTLoggingParams_enableIoTLoggingParams_LogLevel != null) { requestActionParams_actionParams_EnableIoTLoggingParams.LogLevel = requestActionParams_actionParams_EnableIoTLoggingParams_enableIoTLoggingParams_LogLevel; requestActionParams_actionParams_EnableIoTLoggingParamsIsNull = false; } System.String requestActionParams_actionParams_EnableIoTLoggingParams_enableIoTLoggingParams_RoleArnForLogging = null; if (cmdletContext.EnableIoTLoggingParams_RoleArnForLogging != null) { requestActionParams_actionParams_EnableIoTLoggingParams_enableIoTLoggingParams_RoleArnForLogging = cmdletContext.EnableIoTLoggingParams_RoleArnForLogging; } if (requestActionParams_actionParams_EnableIoTLoggingParams_enableIoTLoggingParams_RoleArnForLogging != null) { requestActionParams_actionParams_EnableIoTLoggingParams.RoleArnForLogging = requestActionParams_actionParams_EnableIoTLoggingParams_enableIoTLoggingParams_RoleArnForLogging; requestActionParams_actionParams_EnableIoTLoggingParamsIsNull = false; } // determine if requestActionParams_actionParams_EnableIoTLoggingParams should be set to null if (requestActionParams_actionParams_EnableIoTLoggingParamsIsNull) { requestActionParams_actionParams_EnableIoTLoggingParams = null; } if (requestActionParams_actionParams_EnableIoTLoggingParams != null) { request.ActionParams.EnableIoTLoggingParams = requestActionParams_actionParams_EnableIoTLoggingParams; requestActionParamsIsNull = false; } // determine if request.ActionParams should be set to null if (requestActionParamsIsNull) { request.ActionParams = null; } if (cmdletContext.RoleArn != null) { request.RoleArn = cmdletContext.RoleArn; } 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.UpdateMitigationActionResponse CallAWSServiceOperation(IAmazonIoT client, Amazon.IoT.Model.UpdateMitigationActionRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS IoT", "UpdateMitigationAction"); try { #if DESKTOP return client.UpdateMitigationAction(request); #elif CORECLR return client.UpdateMitigationActionAsync(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 System.String ActionName { get; set; } public System.Boolean? AddThingsToThingGroupParams_OverrideDynamicGroup { get; set; } public List AddThingsToThingGroupParams_ThingGroupName { get; set; } public Amazon.IoT.LogLevel EnableIoTLoggingParams_LogLevel { get; set; } public System.String EnableIoTLoggingParams_RoleArnForLogging { get; set; } public System.String PublishFindingToSnsParams_TopicArn { get; set; } public Amazon.IoT.PolicyTemplateName ReplaceDefaultPolicyVersionParams_TemplateName { get; set; } public Amazon.IoT.CACertificateUpdateAction UpdateCACertificateParams_Action { get; set; } public Amazon.IoT.DeviceCertificateUpdateAction UpdateDeviceCertificateParams_Action { get; set; } public System.String RoleArn { get; set; } public System.Func Select { get; set; } = (response, cmdlet) => response; } } }