/******************************************************************************* * 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.ConfigService; using Amazon.ConfigService.Model; namespace Amazon.PowerShell.Cmdlets.CFG { /// <summary> /// Adds or updates an Config rule to evaluate if your Amazon Web Services resources comply /// with your desired configurations. For information on how many Config rules you can /// have per account, see <a href="https://docs.aws.amazon.com/config/latest/developerguide/configlimits.html"><b>Service Limits</b></a> in the <i>Config Developer Guide</i>. /// /// /// <para> /// There are two types of rules: <i>Config Managed Rules</i> and <i>Config Custom Rules</i>. /// You can use <code>PutConfigRule</code> to create both Config Managed Rules and Config /// Custom Rules. /// </para><para> /// Config Managed Rules are predefined, customizable rules created by Config. For a list /// of managed rules, see <a href="https://docs.aws.amazon.com/config/latest/developerguide/managed-rules-by-aws-config.html">List /// of Config Managed Rules</a>. If you are adding an Config managed rule, you must specify /// the rule's identifier for the <code>SourceIdentifier</code> key. /// </para><para> /// Config Custom Rules are rules that you create from scratch. There are two ways to /// create Config custom rules: with Lambda functions (<a href="https://docs.aws.amazon.com/config/latest/developerguide/gettingstarted-concepts.html#gettingstarted-concepts-function"> /// Lambda Developer Guide</a>) and with Guard (<a href="https://github.com/aws-cloudformation/cloudformation-guard">Guard /// GitHub Repository</a>), a policy-as-code language. Config custom rules created with /// Lambda are called <i>Config Custom Lambda Rules</i> and Config custom rules created /// with Guard are called <i>Config Custom Policy Rules</i>. /// </para><para> /// If you are adding a new Config Custom Lambda rule, you first need to create an Lambda /// function that the rule invokes to evaluate your resources. When you use <code>PutConfigRule</code> /// to add a Custom Lambda rule to Config, you must specify the Amazon Resource Name (ARN) /// that Lambda assigns to the function. You specify the ARN in the <code>SourceIdentifier</code> /// key. This key is part of the <code>Source</code> object, which is part of the <code>ConfigRule</code> /// object. /// </para><para> /// For any new Config rule that you add, specify the <code>ConfigRuleName</code> in the /// <code>ConfigRule</code> object. Do not specify the <code>ConfigRuleArn</code> or the /// <code>ConfigRuleId</code>. These values are generated by Config for new rules. /// </para><para> /// If you are updating a rule that you added previously, you can specify the rule by /// <code>ConfigRuleName</code>, <code>ConfigRuleId</code>, or <code>ConfigRuleArn</code> /// in the <code>ConfigRule</code> data type that you use in this request. /// </para><para> /// For more information about developing and using Config rules, see <a href="https://docs.aws.amazon.com/config/latest/developerguide/evaluate-config.html">Evaluating /// Resources with Config Rules</a> in the <i>Config Developer Guide</i>. /// </para><note><para><code>PutConfigRule</code> is an idempotent API. Subsequent requests won’t create /// a duplicate resource if one was already created. If a following request has different /// <code>tags</code> values, Config will ignore these differences and treat it as an /// idempotent request of the previous. In this case, <code>tags</code> will not be updated, /// even if they are different. /// </para></note> /// </summary> [Cmdlet("Write", "CFGConfigRule", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)] [OutputType("None")] [AWSCmdlet("Calls the AWS Config PutConfigRule API operation.", Operation = new[] {"PutConfigRule"}, SelectReturnType = typeof(Amazon.ConfigService.Model.PutConfigRuleResponse))] [AWSCmdletOutput("None or Amazon.ConfigService.Model.PutConfigRuleResponse", "This cmdlet does not generate any output." + "The service response (type Amazon.ConfigService.Model.PutConfigRuleResponse) can be referenced from properties attached to the cmdlet entry in the $AWSHistory stack." )] public partial class WriteCFGConfigRuleCmdlet : AmazonConfigServiceClientCmdlet, IExecutor { #region Parameter Scope_ComplianceResourceId /// <summary> /// <para> /// <para>The ID of the only Amazon Web Services resource that you want to trigger an evaluation /// for the rule. If you specify a resource ID, you must specify one resource type for /// <code>ComplianceResourceTypes</code>.</para> /// </para> /// </summary> [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ConfigRule_Scope_ComplianceResourceId")] public System.String Scope_ComplianceResourceId { get; set; } #endregion #region Parameter Scope_ComplianceResourceType /// <summary> /// <para> /// <para>The resource types of only those Amazon Web Services resources that you want to trigger /// an evaluation for the rule. You can only specify one type if you also specify a resource /// ID for <code>ComplianceResourceId</code>.</para> /// </para> /// </summary> [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ConfigRule_Scope_ComplianceResourceTypes")] public System.String[] Scope_ComplianceResourceType { get; set; } #endregion #region Parameter ConfigRule_ConfigRuleArn /// <summary> /// <para> /// <para>The Amazon Resource Name (ARN) of the Config rule.</para> /// </para> /// </summary> [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String ConfigRule_ConfigRuleArn { get; set; } #endregion #region Parameter ConfigRule_ConfigRuleId /// <summary> /// <para> /// <para>The ID of the Config rule.</para> /// </para> /// </summary> [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String ConfigRule_ConfigRuleId { get; set; } #endregion #region Parameter ConfigRule_ConfigRuleName /// <summary> /// <para> /// <para>The name that you assign to the Config rule. The name is required if you are adding /// a new rule.</para> /// </para> /// </summary> [System.Management.Automation.Parameter(Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true)] public System.String ConfigRule_ConfigRuleName { get; set; } #endregion #region Parameter ConfigRule_ConfigRuleState /// <summary> /// <para> /// <para>Indicates whether the Config rule is active or is currently being deleted by Config. /// It can also indicate the evaluation status for the Config rule.</para><para>Config sets the state of the rule to <code>EVALUATING</code> temporarily after you /// use the <code>StartConfigRulesEvaluation</code> request to evaluate your resources /// against the Config rule.</para><para>Config sets the state of the rule to <code>DELETING_RESULTS</code> temporarily after /// you use the <code>DeleteEvaluationResults</code> request to delete the current evaluation /// results for the Config rule.</para><para>Config temporarily sets the state of a rule to <code>DELETING</code> after you use /// the <code>DeleteConfigRule</code> request to delete the rule. After Config deletes /// the rule, the rule and all of its evaluations are erased and are no longer available.</para> /// </para> /// </summary> [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [AWSConstantClassSource("Amazon.ConfigService.ConfigRuleState")] public Amazon.ConfigService.ConfigRuleState ConfigRule_ConfigRuleState { get; set; } #endregion #region Parameter ConfigRule_CreatedBy /// <summary> /// <para> /// <para>Service principal name of the service that created the rule.</para><note><para>The field is populated only if the service-linked rule is created by a service. The /// field is empty if you create your own rule.</para></note> /// </para> /// </summary> [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String ConfigRule_CreatedBy { get; set; } #endregion #region Parameter ConfigRule_Description /// <summary> /// <para> /// <para>The description that you provide for the Config rule.</para> /// </para> /// </summary> [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String ConfigRule_Description { get; set; } #endregion #region Parameter CustomPolicyDetails_EnableDebugLogDelivery /// <summary> /// <para> /// <para>The boolean expression for enabling debug logging for your Config Custom Policy rule. /// The default value is <code>false</code>.</para> /// </para> /// </summary> [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ConfigRule_Source_CustomPolicyDetails_EnableDebugLogDelivery")] public System.Boolean? CustomPolicyDetails_EnableDebugLogDelivery { get; set; } #endregion #region Parameter ConfigRule_EvaluationMode /// <summary> /// <para> /// <para>The modes the Config rule can be evaluated in. The valid values are distinct objects. /// By default, the value is Detective evaluation mode only.</para> /// </para> /// </summary> [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ConfigRule_EvaluationModes")] public Amazon.ConfigService.Model.EvaluationModeConfiguration[] ConfigRule_EvaluationMode { get; set; } #endregion #region Parameter ConfigRule_InputParameter /// <summary> /// <para> /// <para>A string, in JSON format, that is passed to the Config rule Lambda function.</para> /// </para> /// </summary> [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ConfigRule_InputParameters")] public System.String ConfigRule_InputParameter { get; set; } #endregion #region Parameter ConfigRule_MaximumExecutionFrequency /// <summary> /// <para> /// <para>The maximum frequency with which Config runs evaluations for a rule. You can specify /// a value for <code>MaximumExecutionFrequency</code> when:</para><ul><li><para>This is for an Config managed rule that is triggered at a periodic frequency.</para></li><li><para>Your custom rule is triggered when Config delivers the configuration snapshot. For /// more information, see <a>ConfigSnapshotDeliveryProperties</a>.</para></li></ul><note><para>By default, rules with a periodic trigger are evaluated every 24 hours. To change /// the frequency, specify a valid value for the <code>MaximumExecutionFrequency</code> /// parameter.</para></note> /// </para> /// </summary> [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [AWSConstantClassSource("Amazon.ConfigService.MaximumExecutionFrequency")] public Amazon.ConfigService.MaximumExecutionFrequency ConfigRule_MaximumExecutionFrequency { get; set; } #endregion #region Parameter Source_Owner /// <summary> /// <para> /// <para>Indicates whether Amazon Web Services or the customer owns and manages the Config /// rule.</para><para>Config Managed Rules are predefined rules owned by Amazon Web Services. For more information, /// see <a href="https://docs.aws.amazon.com/config/latest/developerguide/evaluate-config_use-managed-rules.html">Config /// Managed Rules</a> in the <i>Config developer guide</i>.</para><para>Config Custom Rules are rules that you can develop either with Guard (<code>CUSTOM_POLICY</code>) /// or Lambda (<code>CUSTOM_LAMBDA</code>). For more information, see <a href="https://docs.aws.amazon.com/config/latest/developerguide/evaluate-config_develop-rules.html">Config /// Custom Rules </a> in the <i>Config developer guide</i>.</para> /// </para> /// </summary> #if !MODULAR [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] #else [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)] [System.Management.Automation.AllowNull] #endif [Amazon.PowerShell.Common.AWSRequiredParameter] [Alias("ConfigRule_Source_Owner")] [AWSConstantClassSource("Amazon.ConfigService.Owner")] public Amazon.ConfigService.Owner Source_Owner { get; set; } #endregion #region Parameter CustomPolicyDetails_PolicyRuntime /// <summary> /// <para> /// <para>The runtime system for your Config Custom Policy rule. Guard is a policy-as-code language /// that allows you to write policies that are enforced by Config Custom Policy rules. /// For more information about Guard, see the <a href="https://github.com/aws-cloudformation/cloudformation-guard">Guard /// GitHub Repository</a>.</para> /// </para> /// </summary> [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ConfigRule_Source_CustomPolicyDetails_PolicyRuntime")] public System.String CustomPolicyDetails_PolicyRuntime { get; set; } #endregion #region Parameter CustomPolicyDetails_PolicyText /// <summary> /// <para> /// <para>The policy definition containing the logic for your Config Custom Policy rule.</para> /// </para> /// </summary> [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ConfigRule_Source_CustomPolicyDetails_PolicyText")] public System.String CustomPolicyDetails_PolicyText { get; set; } #endregion #region Parameter Source_SourceDetail /// <summary> /// <para> /// <para>Provides the source and the message types that cause Config to evaluate your Amazon /// Web Services resources against a rule. It also provides the frequency with which you /// want Config to run evaluations for the rule if the trigger type is periodic.</para><para>If the owner is set to <code>CUSTOM_POLICY</code>, the only acceptable values for /// the Config rule trigger message type are <code>ConfigurationItemChangeNotification</code> /// and <code>OversizedConfigurationItemChangeNotification</code>.</para> /// </para> /// </summary> [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ConfigRule_Source_SourceDetails")] public Amazon.ConfigService.Model.SourceDetail[] Source_SourceDetail { get; set; } #endregion #region Parameter Source_SourceIdentifier /// <summary> /// <para> /// <para>For Config Managed rules, a predefined identifier from a list. For example, <code>IAM_PASSWORD_POLICY</code> /// is a managed rule. To reference a managed rule, see <a href="https://docs.aws.amazon.com/config/latest/developerguide/managed-rules-by-aws-config.html">List /// of Config Managed Rules</a>.</para><para>For Config Custom Lambda rules, the identifier is the Amazon Resource Name (ARN) of /// the rule's Lambda function, such as <code>arn:aws:lambda:us-east-2:123456789012:function:custom_rule_name</code>.</para><para>For Config Custom Policy rules, this field will be ignored.</para> /// </para> /// </summary> [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ConfigRule_Source_SourceIdentifier")] public System.String Source_SourceIdentifier { get; set; } #endregion #region Parameter Scope_TagKey /// <summary> /// <para> /// <para>The tag key that is applied to only those Amazon Web Services resources that you want /// to trigger an evaluation for the rule.</para> /// </para> /// </summary> [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ConfigRule_Scope_TagKey")] public System.String Scope_TagKey { get; set; } #endregion #region Parameter Tag /// <summary> /// <para> /// <para>An array of tag object.</para> /// </para> /// </summary> [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("Tags")] public Amazon.ConfigService.Model.Tag[] Tag { get; set; } #endregion #region Parameter Scope_TagValue /// <summary> /// <para> /// <para>The tag value applied to only those Amazon Web Services resources that you want to /// trigger an evaluation for the rule. If you specify a value for <code>TagValue</code>, /// you must also specify a value for <code>TagKey</code>.</para> /// </para> /// </summary> [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("ConfigRule_Scope_TagValue")] public System.String Scope_TagValue { get; set; } #endregion #region Parameter Select /// <summary> /// 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.ConfigService.Model.PutConfigRuleResponse). /// Specifying -Select '^ParameterName' will result in the cmdlet returning the selected cmdlet parameter value. /// </summary> [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public string Select { get; set; } = "*"; #endregion #region Parameter PassThru /// <summary> /// Changes the cmdlet behavior to return the value passed to the ConfigRule_ConfigRuleName parameter. /// The -PassThru parameter is deprecated, use -Select '^ConfigRule_ConfigRuleName' instead. This parameter will be removed in a future version. /// </summary> [System.Obsolete("The -PassThru parameter is deprecated, use -Select '^ConfigRule_ConfigRuleName' 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 /// <summary> /// This parameter overrides confirmation prompts to force /// the cmdlet to continue its operation. This parameter should always /// be used with caution. /// </summary> [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.ConfigRule_ConfigRuleName), MyInvocation.BoundParameters); if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Write-CFGConfigRule (PutConfigRule)")) { 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<Amazon.ConfigService.Model.PutConfigRuleResponse, WriteCFGConfigRuleCmdlet>(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.ConfigRule_ConfigRuleName; } #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute context.ConfigRule_ConfigRuleArn = this.ConfigRule_ConfigRuleArn; context.ConfigRule_ConfigRuleId = this.ConfigRule_ConfigRuleId; context.ConfigRule_ConfigRuleName = this.ConfigRule_ConfigRuleName; context.ConfigRule_ConfigRuleState = this.ConfigRule_ConfigRuleState; context.ConfigRule_CreatedBy = this.ConfigRule_CreatedBy; context.ConfigRule_Description = this.ConfigRule_Description; if (this.ConfigRule_EvaluationMode != null) { context.ConfigRule_EvaluationMode = new List<Amazon.ConfigService.Model.EvaluationModeConfiguration>(this.ConfigRule_EvaluationMode); } context.ConfigRule_InputParameter = this.ConfigRule_InputParameter; context.ConfigRule_MaximumExecutionFrequency = this.ConfigRule_MaximumExecutionFrequency; context.Scope_ComplianceResourceId = this.Scope_ComplianceResourceId; if (this.Scope_ComplianceResourceType != null) { context.Scope_ComplianceResourceType = new List<System.String>(this.Scope_ComplianceResourceType); } context.Scope_TagKey = this.Scope_TagKey; context.Scope_TagValue = this.Scope_TagValue; context.CustomPolicyDetails_EnableDebugLogDelivery = this.CustomPolicyDetails_EnableDebugLogDelivery; context.CustomPolicyDetails_PolicyRuntime = this.CustomPolicyDetails_PolicyRuntime; context.CustomPolicyDetails_PolicyText = this.CustomPolicyDetails_PolicyText; context.Source_Owner = this.Source_Owner; #if MODULAR if (this.Source_Owner == null && ParameterWasBound(nameof(this.Source_Owner))) { WriteWarning("You are passing $null as a value for parameter Source_Owner 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 if (this.Source_SourceDetail != null) { context.Source_SourceDetail = new List<Amazon.ConfigService.Model.SourceDetail>(this.Source_SourceDetail); } context.Source_SourceIdentifier = this.Source_SourceIdentifier; if (this.Tag != null) { context.Tag = new List<Amazon.ConfigService.Model.Tag>(this.Tag); } // 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.ConfigService.Model.PutConfigRuleRequest(); // populate ConfigRule var requestConfigRuleIsNull = true; request.ConfigRule = new Amazon.ConfigService.Model.ConfigRule(); System.String requestConfigRule_configRule_ConfigRuleArn = null; if (cmdletContext.ConfigRule_ConfigRuleArn != null) { requestConfigRule_configRule_ConfigRuleArn = cmdletContext.ConfigRule_ConfigRuleArn; } if (requestConfigRule_configRule_ConfigRuleArn != null) { request.ConfigRule.ConfigRuleArn = requestConfigRule_configRule_ConfigRuleArn; requestConfigRuleIsNull = false; } System.String requestConfigRule_configRule_ConfigRuleId = null; if (cmdletContext.ConfigRule_ConfigRuleId != null) { requestConfigRule_configRule_ConfigRuleId = cmdletContext.ConfigRule_ConfigRuleId; } if (requestConfigRule_configRule_ConfigRuleId != null) { request.ConfigRule.ConfigRuleId = requestConfigRule_configRule_ConfigRuleId; requestConfigRuleIsNull = false; } System.String requestConfigRule_configRule_ConfigRuleName = null; if (cmdletContext.ConfigRule_ConfigRuleName != null) { requestConfigRule_configRule_ConfigRuleName = cmdletContext.ConfigRule_ConfigRuleName; } if (requestConfigRule_configRule_ConfigRuleName != null) { request.ConfigRule.ConfigRuleName = requestConfigRule_configRule_ConfigRuleName; requestConfigRuleIsNull = false; } Amazon.ConfigService.ConfigRuleState requestConfigRule_configRule_ConfigRuleState = null; if (cmdletContext.ConfigRule_ConfigRuleState != null) { requestConfigRule_configRule_ConfigRuleState = cmdletContext.ConfigRule_ConfigRuleState; } if (requestConfigRule_configRule_ConfigRuleState != null) { request.ConfigRule.ConfigRuleState = requestConfigRule_configRule_ConfigRuleState; requestConfigRuleIsNull = false; } System.String requestConfigRule_configRule_CreatedBy = null; if (cmdletContext.ConfigRule_CreatedBy != null) { requestConfigRule_configRule_CreatedBy = cmdletContext.ConfigRule_CreatedBy; } if (requestConfigRule_configRule_CreatedBy != null) { request.ConfigRule.CreatedBy = requestConfigRule_configRule_CreatedBy; requestConfigRuleIsNull = false; } System.String requestConfigRule_configRule_Description = null; if (cmdletContext.ConfigRule_Description != null) { requestConfigRule_configRule_Description = cmdletContext.ConfigRule_Description; } if (requestConfigRule_configRule_Description != null) { request.ConfigRule.Description = requestConfigRule_configRule_Description; requestConfigRuleIsNull = false; } List<Amazon.ConfigService.Model.EvaluationModeConfiguration> requestConfigRule_configRule_EvaluationMode = null; if (cmdletContext.ConfigRule_EvaluationMode != null) { requestConfigRule_configRule_EvaluationMode = cmdletContext.ConfigRule_EvaluationMode; } if (requestConfigRule_configRule_EvaluationMode != null) { request.ConfigRule.EvaluationModes = requestConfigRule_configRule_EvaluationMode; requestConfigRuleIsNull = false; } System.String requestConfigRule_configRule_InputParameter = null; if (cmdletContext.ConfigRule_InputParameter != null) { requestConfigRule_configRule_InputParameter = cmdletContext.ConfigRule_InputParameter; } if (requestConfigRule_configRule_InputParameter != null) { request.ConfigRule.InputParameters = requestConfigRule_configRule_InputParameter; requestConfigRuleIsNull = false; } Amazon.ConfigService.MaximumExecutionFrequency requestConfigRule_configRule_MaximumExecutionFrequency = null; if (cmdletContext.ConfigRule_MaximumExecutionFrequency != null) { requestConfigRule_configRule_MaximumExecutionFrequency = cmdletContext.ConfigRule_MaximumExecutionFrequency; } if (requestConfigRule_configRule_MaximumExecutionFrequency != null) { request.ConfigRule.MaximumExecutionFrequency = requestConfigRule_configRule_MaximumExecutionFrequency; requestConfigRuleIsNull = false; } Amazon.ConfigService.Model.Scope requestConfigRule_configRule_Scope = null; // populate Scope var requestConfigRule_configRule_ScopeIsNull = true; requestConfigRule_configRule_Scope = new Amazon.ConfigService.Model.Scope(); System.String requestConfigRule_configRule_Scope_scope_ComplianceResourceId = null; if (cmdletContext.Scope_ComplianceResourceId != null) { requestConfigRule_configRule_Scope_scope_ComplianceResourceId = cmdletContext.Scope_ComplianceResourceId; } if (requestConfigRule_configRule_Scope_scope_ComplianceResourceId != null) { requestConfigRule_configRule_Scope.ComplianceResourceId = requestConfigRule_configRule_Scope_scope_ComplianceResourceId; requestConfigRule_configRule_ScopeIsNull = false; } List<System.String> requestConfigRule_configRule_Scope_scope_ComplianceResourceType = null; if (cmdletContext.Scope_ComplianceResourceType != null) { requestConfigRule_configRule_Scope_scope_ComplianceResourceType = cmdletContext.Scope_ComplianceResourceType; } if (requestConfigRule_configRule_Scope_scope_ComplianceResourceType != null) { requestConfigRule_configRule_Scope.ComplianceResourceTypes = requestConfigRule_configRule_Scope_scope_ComplianceResourceType; requestConfigRule_configRule_ScopeIsNull = false; } System.String requestConfigRule_configRule_Scope_scope_TagKey = null; if (cmdletContext.Scope_TagKey != null) { requestConfigRule_configRule_Scope_scope_TagKey = cmdletContext.Scope_TagKey; } if (requestConfigRule_configRule_Scope_scope_TagKey != null) { requestConfigRule_configRule_Scope.TagKey = requestConfigRule_configRule_Scope_scope_TagKey; requestConfigRule_configRule_ScopeIsNull = false; } System.String requestConfigRule_configRule_Scope_scope_TagValue = null; if (cmdletContext.Scope_TagValue != null) { requestConfigRule_configRule_Scope_scope_TagValue = cmdletContext.Scope_TagValue; } if (requestConfigRule_configRule_Scope_scope_TagValue != null) { requestConfigRule_configRule_Scope.TagValue = requestConfigRule_configRule_Scope_scope_TagValue; requestConfigRule_configRule_ScopeIsNull = false; } // determine if requestConfigRule_configRule_Scope should be set to null if (requestConfigRule_configRule_ScopeIsNull) { requestConfigRule_configRule_Scope = null; } if (requestConfigRule_configRule_Scope != null) { request.ConfigRule.Scope = requestConfigRule_configRule_Scope; requestConfigRuleIsNull = false; } Amazon.ConfigService.Model.Source requestConfigRule_configRule_Source = null; // populate Source var requestConfigRule_configRule_SourceIsNull = true; requestConfigRule_configRule_Source = new Amazon.ConfigService.Model.Source(); Amazon.ConfigService.Owner requestConfigRule_configRule_Source_source_Owner = null; if (cmdletContext.Source_Owner != null) { requestConfigRule_configRule_Source_source_Owner = cmdletContext.Source_Owner; } if (requestConfigRule_configRule_Source_source_Owner != null) { requestConfigRule_configRule_Source.Owner = requestConfigRule_configRule_Source_source_Owner; requestConfigRule_configRule_SourceIsNull = false; } List<Amazon.ConfigService.Model.SourceDetail> requestConfigRule_configRule_Source_source_SourceDetail = null; if (cmdletContext.Source_SourceDetail != null) { requestConfigRule_configRule_Source_source_SourceDetail = cmdletContext.Source_SourceDetail; } if (requestConfigRule_configRule_Source_source_SourceDetail != null) { requestConfigRule_configRule_Source.SourceDetails = requestConfigRule_configRule_Source_source_SourceDetail; requestConfigRule_configRule_SourceIsNull = false; } System.String requestConfigRule_configRule_Source_source_SourceIdentifier = null; if (cmdletContext.Source_SourceIdentifier != null) { requestConfigRule_configRule_Source_source_SourceIdentifier = cmdletContext.Source_SourceIdentifier; } if (requestConfigRule_configRule_Source_source_SourceIdentifier != null) { requestConfigRule_configRule_Source.SourceIdentifier = requestConfigRule_configRule_Source_source_SourceIdentifier; requestConfigRule_configRule_SourceIsNull = false; } Amazon.ConfigService.Model.CustomPolicyDetails requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails = null; // populate CustomPolicyDetails var requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetailsIsNull = true; requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails = new Amazon.ConfigService.Model.CustomPolicyDetails(); System.Boolean? requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails_customPolicyDetails_EnableDebugLogDelivery = null; if (cmdletContext.CustomPolicyDetails_EnableDebugLogDelivery != null) { requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails_customPolicyDetails_EnableDebugLogDelivery = cmdletContext.CustomPolicyDetails_EnableDebugLogDelivery.Value; } if (requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails_customPolicyDetails_EnableDebugLogDelivery != null) { requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails.EnableDebugLogDelivery = requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails_customPolicyDetails_EnableDebugLogDelivery.Value; requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetailsIsNull = false; } System.String requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails_customPolicyDetails_PolicyRuntime = null; if (cmdletContext.CustomPolicyDetails_PolicyRuntime != null) { requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails_customPolicyDetails_PolicyRuntime = cmdletContext.CustomPolicyDetails_PolicyRuntime; } if (requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails_customPolicyDetails_PolicyRuntime != null) { requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails.PolicyRuntime = requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails_customPolicyDetails_PolicyRuntime; requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetailsIsNull = false; } System.String requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails_customPolicyDetails_PolicyText = null; if (cmdletContext.CustomPolicyDetails_PolicyText != null) { requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails_customPolicyDetails_PolicyText = cmdletContext.CustomPolicyDetails_PolicyText; } if (requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails_customPolicyDetails_PolicyText != null) { requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails.PolicyText = requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails_customPolicyDetails_PolicyText; requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetailsIsNull = false; } // determine if requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails should be set to null if (requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetailsIsNull) { requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails = null; } if (requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails != null) { requestConfigRule_configRule_Source.CustomPolicyDetails = requestConfigRule_configRule_Source_configRule_Source_CustomPolicyDetails; requestConfigRule_configRule_SourceIsNull = false; } // determine if requestConfigRule_configRule_Source should be set to null if (requestConfigRule_configRule_SourceIsNull) { requestConfigRule_configRule_Source = null; } if (requestConfigRule_configRule_Source != null) { request.ConfigRule.Source = requestConfigRule_configRule_Source; requestConfigRuleIsNull = false; } // determine if request.ConfigRule should be set to null if (requestConfigRuleIsNull) { request.ConfigRule = null; } if (cmdletContext.Tag != null) { request.Tags = cmdletContext.Tag; } 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.ConfigService.Model.PutConfigRuleResponse CallAWSServiceOperation(IAmazonConfigService client, Amazon.ConfigService.Model.PutConfigRuleRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Config", "PutConfigRule"); try { #if DESKTOP return client.PutConfigRule(request); #elif CORECLR return client.PutConfigRuleAsync(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 ConfigRule_ConfigRuleArn { get; set; } public System.String ConfigRule_ConfigRuleId { get; set; } public System.String ConfigRule_ConfigRuleName { get; set; } public Amazon.ConfigService.ConfigRuleState ConfigRule_ConfigRuleState { get; set; } public System.String ConfigRule_CreatedBy { get; set; } public System.String ConfigRule_Description { get; set; } public List<Amazon.ConfigService.Model.EvaluationModeConfiguration> ConfigRule_EvaluationMode { get; set; } public System.String ConfigRule_InputParameter { get; set; } public Amazon.ConfigService.MaximumExecutionFrequency ConfigRule_MaximumExecutionFrequency { get; set; } public System.String Scope_ComplianceResourceId { get; set; } public List<System.String> Scope_ComplianceResourceType { get; set; } public System.String Scope_TagKey { get; set; } public System.String Scope_TagValue { get; set; } public System.Boolean? CustomPolicyDetails_EnableDebugLogDelivery { get; set; } public System.String CustomPolicyDetails_PolicyRuntime { get; set; } public System.String CustomPolicyDetails_PolicyText { get; set; } public Amazon.ConfigService.Owner Source_Owner { get; set; } public List<Amazon.ConfigService.Model.SourceDetail> Source_SourceDetail { get; set; } public System.String Source_SourceIdentifier { get; set; } public List<Amazon.ConfigService.Model.Tag> Tag { get; set; } public System.Func<Amazon.ConfigService.Model.PutConfigRuleResponse, WriteCFGConfigRuleCmdlet, object> Select { get; set; } = (response, cmdlet) => null; } } }