/*******************************************************************************
* 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.NetworkFirewall;
using Amazon.NetworkFirewall.Model;
namespace Amazon.PowerShell.Cmdlets.NWFW
{
///
/// Creates the firewall policy for the firewall according to the specifications.
///
///
///
/// An Network Firewall firewall policy defines the behavior of a firewall, in a collection
/// of stateless and stateful rule groups and other settings. You can use one firewall
/// policy for multiple firewalls.
///
///
[Cmdlet("New", "NWFWFirewallPolicy", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)]
[OutputType("Amazon.NetworkFirewall.Model.CreateFirewallPolicyResponse")]
[AWSCmdlet("Calls the AWS Network Firewall CreateFirewallPolicy API operation.", Operation = new[] {"CreateFirewallPolicy"}, SelectReturnType = typeof(Amazon.NetworkFirewall.Model.CreateFirewallPolicyResponse))]
[AWSCmdletOutput("Amazon.NetworkFirewall.Model.CreateFirewallPolicyResponse",
"This cmdlet returns an Amazon.NetworkFirewall.Model.CreateFirewallPolicyResponse object containing multiple properties. The object can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack."
)]
public partial class NewNWFWFirewallPolicyCmdlet : AmazonNetworkFirewallClientCmdlet, IExecutor
{
#region Parameter Description
///
///
/// A description of the firewall policy.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String Description { get; set; }
#endregion
#region Parameter DryRun
///
///
/// Indicates whether you want Network Firewall to just check the validity of the request,
/// rather than run the request. If set to TRUE
, Network Firewall checks whether the request can run successfully,
/// but doesn't actually make the requested changes. The call returns the value that the
/// request would return if you ran it with dry run set to FALSE
, but doesn't
/// make additions or changes to your resources. This option allows you to make sure that
/// you have the required permissions to run the request and that your request parameters
/// are valid. If set to FALSE
, Network Firewall makes the requested changes to your
/// resources.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Boolean? DryRun { get; set; }
#endregion
#region Parameter FirewallPolicyName
///
///
/// The descriptive name of the firewall policy. You can't change the name of a firewall
/// policy after you create it.
///
///
#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 FirewallPolicyName { get; set; }
#endregion
#region Parameter EncryptionConfiguration_KeyId
///
///
/// The ID of the Amazon Web Services Key Management Service (KMS) customer managed key.
/// You can use any of the key identifiers that KMS supports, unless you're using a key
/// that's managed by another account. If you're using a key managed by another account,
/// then specify the key ARN. For more information, see Key
/// ID in the Amazon Web Services KMS Developer Guide.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String EncryptionConfiguration_KeyId { get; set; }
#endregion
#region Parameter StatefulEngineOptions_RuleOrder
///
///
/// Indicates how to manage the order of stateful rule evaluation for the policy. DEFAULT_ACTION_ORDER
/// is the default behavior. Stateful rules are provided to the rule engine as Suricata
/// compatible strings, and Suricata evaluates them based on certain settings. For more
/// information, see Evaluation
/// order for stateful rules in the Network Firewall Developer Guide.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("FirewallPolicy_StatefulEngineOptions_RuleOrder")]
[AWSConstantClassSource("Amazon.NetworkFirewall.RuleOrder")]
public Amazon.NetworkFirewall.RuleOrder StatefulEngineOptions_RuleOrder { get; set; }
#endregion
#region Parameter PolicyVariables_RuleVariable
///
///
/// The IPv4 or IPv6 addresses in CIDR notation to use for the Suricata HOME_NET
/// variable. If your firewall uses an inspection VPC, you might want to override the
/// HOME_NET
variable with the CIDRs of your home networks. If you don't
/// override HOME_NET
with your own CIDRs, Network Firewall by default uses
/// the CIDR of your inspection VPC.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("FirewallPolicy_PolicyVariables_RuleVariables")]
public System.Collections.Hashtable PolicyVariables_RuleVariable { get; set; }
#endregion
#region Parameter FirewallPolicy_StatefulDefaultAction
///
///
/// The default actions to take on a packet that doesn't match any stateful rules. The
/// stateful default action is optional, and is only valid when using the strict rule
/// order.Valid values of the stateful default action:- aws:drop_strict
- aws:drop_established
- aws:alert_strict
- aws:alert_established
For more information, see Strict
/// evaluation order in the Network Firewall Developer Guide.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("FirewallPolicy_StatefulDefaultActions")]
public System.String[] FirewallPolicy_StatefulDefaultAction { get; set; }
#endregion
#region Parameter FirewallPolicy_StatefulRuleGroupReference
///
///
/// References to the stateful rule groups that are used in the policy. These define the
/// inspection criteria in stateful rules.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("FirewallPolicy_StatefulRuleGroupReferences")]
public Amazon.NetworkFirewall.Model.StatefulRuleGroupReference[] FirewallPolicy_StatefulRuleGroupReference { get; set; }
#endregion
#region Parameter FirewallPolicy_StatelessCustomAction
///
///
/// The custom action definitions that are available for use in the firewall policy's
/// StatelessDefaultActions
setting. You name each custom action that you
/// define, and then you can use it by name in your default actions specifications.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("FirewallPolicy_StatelessCustomActions")]
public Amazon.NetworkFirewall.Model.CustomAction[] FirewallPolicy_StatelessCustomAction { get; set; }
#endregion
#region Parameter FirewallPolicy_StatelessDefaultAction
///
///
/// The actions to take on a packet if it doesn't match any of the stateless rules in
/// the policy. If you want non-matching packets to be forwarded for stateful inspection,
/// specify aws:forward_to_sfe
. You must specify one of the standard actions: aws:pass
, aws:drop
,
/// or aws:forward_to_sfe
. In addition, you can specify custom actions that
/// are compatible with your standard section choice.For example, you could specify ["aws:pass"]
or you could specify ["aws:pass",
/// “customActionName”]
. For information about compatibility, see the custom action
/// descriptions under CustomAction.
///
///
#if !MODULAR
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
#else
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)]
[System.Management.Automation.AllowEmptyCollection]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
[Alias("FirewallPolicy_StatelessDefaultActions")]
public System.String[] FirewallPolicy_StatelessDefaultAction { get; set; }
#endregion
#region Parameter FirewallPolicy_StatelessFragmentDefaultAction
///
///
/// The actions to take on a fragmented UDP packet if it doesn't match any of the stateless
/// rules in the policy. Network Firewall only manages UDP packet fragments and silently
/// drops packet fragments for other protocols. If you want non-matching fragmented UDP
/// packets to be forwarded for stateful inspection, specify aws:forward_to_sfe
.
/// You must specify one of the standard actions: aws:pass
, aws:drop
,
/// or aws:forward_to_sfe
. In addition, you can specify custom actions that
/// are compatible with your standard section choice.For example, you could specify ["aws:pass"]
or you could specify ["aws:pass",
/// “customActionName”]
. For information about compatibility, see the custom action
/// descriptions under CustomAction.
///
///
#if !MODULAR
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
#else
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)]
[System.Management.Automation.AllowEmptyCollection]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
[Alias("FirewallPolicy_StatelessFragmentDefaultActions")]
public System.String[] FirewallPolicy_StatelessFragmentDefaultAction { get; set; }
#endregion
#region Parameter FirewallPolicy_StatelessRuleGroupReference
///
///
/// References to the stateless rule groups that are used in the policy. These define
/// the matching criteria in stateless rules.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("FirewallPolicy_StatelessRuleGroupReferences")]
public Amazon.NetworkFirewall.Model.StatelessRuleGroupReference[] FirewallPolicy_StatelessRuleGroupReference { get; set; }
#endregion
#region Parameter StatefulEngineOptions_StreamExceptionPolicy
///
///
/// Configures how Network Firewall processes traffic when a network connection breaks
/// midstream. Network connections can break due to disruptions in external networks or
/// within the firewall itself.DROP
- Network Firewall fails closed and drops all subsequent traffic
/// going to the firewall. This is the default behavior.CONTINUE
- Network Firewall continues to apply rules to the subsequent
/// traffic without context from traffic before the break. This impacts the behavior of
/// rules that depend on this context. For example, if you have a stateful rule to drop
/// http
traffic, Network Firewall won't match the traffic for this rule because
/// the service won't have the context from session initialization defining the application
/// layer protocol as HTTP. However, this behavior is rule dependent—a TCP-layer rule
/// using a flow:stateless
rule would still match, as would the aws:drop_strict
/// default action.REJECT
- Network Firewall fails closed and drops all subsequent traffic
/// going to the firewall. Network Firewall also sends a TCP reject packet back to your
/// client so that the client can immediately establish a new session. Network Firewall
/// will have context about the new session and will apply rules to the subsequent traffic.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("FirewallPolicy_StatefulEngineOptions_StreamExceptionPolicy")]
[AWSConstantClassSource("Amazon.NetworkFirewall.StreamExceptionPolicy")]
public Amazon.NetworkFirewall.StreamExceptionPolicy StatefulEngineOptions_StreamExceptionPolicy { get; set; }
#endregion
#region Parameter Tag
///
///
/// The key:value pairs to associate with the resource.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Tags")]
public Amazon.NetworkFirewall.Model.Tag[] Tag { get; set; }
#endregion
#region Parameter FirewallPolicy_TLSInspectionConfigurationArn
///
///
/// The Amazon Resource Name (ARN) of the TLS inspection configuration.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String FirewallPolicy_TLSInspectionConfigurationArn { get; set; }
#endregion
#region Parameter EncryptionConfiguration_Type
///
///
/// The type of Amazon Web Services KMS key to use for encryption of your Network Firewall
/// resources.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[AWSConstantClassSource("Amazon.NetworkFirewall.EncryptionType")]
public Amazon.NetworkFirewall.EncryptionType EncryptionConfiguration_Type { 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.NetworkFirewall.Model.CreateFirewallPolicyResponse).
/// Specifying the name of a property of type Amazon.NetworkFirewall.Model.CreateFirewallPolicyResponse 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 FirewallPolicyName parameter.
/// The -PassThru parameter is deprecated, use -Select '^FirewallPolicyName' instead. This parameter will be removed in a future version.
///
[System.Obsolete("The -PassThru parameter is deprecated, use -Select '^FirewallPolicyName' 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.FirewallPolicyName), MyInvocation.BoundParameters);
if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "New-NWFWFirewallPolicy (CreateFirewallPolicy)"))
{
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.FirewallPolicyName;
}
#pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute
context.Description = this.Description;
context.DryRun = this.DryRun;
context.EncryptionConfiguration_KeyId = this.EncryptionConfiguration_KeyId;
context.EncryptionConfiguration_Type = this.EncryptionConfiguration_Type;
if (this.PolicyVariables_RuleVariable != null)
{
context.PolicyVariables_RuleVariable = new Dictionary(StringComparer.Ordinal);
foreach (var hashKey in this.PolicyVariables_RuleVariable.Keys)
{
context.PolicyVariables_RuleVariable.Add((String)hashKey, (IPSet)(this.PolicyVariables_RuleVariable[hashKey]));
}
}
if (this.FirewallPolicy_StatefulDefaultAction != null)
{
context.FirewallPolicy_StatefulDefaultAction = new List(this.FirewallPolicy_StatefulDefaultAction);
}
context.StatefulEngineOptions_RuleOrder = this.StatefulEngineOptions_RuleOrder;
context.StatefulEngineOptions_StreamExceptionPolicy = this.StatefulEngineOptions_StreamExceptionPolicy;
if (this.FirewallPolicy_StatefulRuleGroupReference != null)
{
context.FirewallPolicy_StatefulRuleGroupReference = new List(this.FirewallPolicy_StatefulRuleGroupReference);
}
if (this.FirewallPolicy_StatelessCustomAction != null)
{
context.FirewallPolicy_StatelessCustomAction = new List(this.FirewallPolicy_StatelessCustomAction);
}
if (this.FirewallPolicy_StatelessDefaultAction != null)
{
context.FirewallPolicy_StatelessDefaultAction = new List(this.FirewallPolicy_StatelessDefaultAction);
}
#if MODULAR
if (this.FirewallPolicy_StatelessDefaultAction == null && ParameterWasBound(nameof(this.FirewallPolicy_StatelessDefaultAction)))
{
WriteWarning("You are passing $null as a value for parameter FirewallPolicy_StatelessDefaultAction 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.FirewallPolicy_StatelessFragmentDefaultAction != null)
{
context.FirewallPolicy_StatelessFragmentDefaultAction = new List(this.FirewallPolicy_StatelessFragmentDefaultAction);
}
#if MODULAR
if (this.FirewallPolicy_StatelessFragmentDefaultAction == null && ParameterWasBound(nameof(this.FirewallPolicy_StatelessFragmentDefaultAction)))
{
WriteWarning("You are passing $null as a value for parameter FirewallPolicy_StatelessFragmentDefaultAction 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.FirewallPolicy_StatelessRuleGroupReference != null)
{
context.FirewallPolicy_StatelessRuleGroupReference = new List(this.FirewallPolicy_StatelessRuleGroupReference);
}
context.FirewallPolicy_TLSInspectionConfigurationArn = this.FirewallPolicy_TLSInspectionConfigurationArn;
context.FirewallPolicyName = this.FirewallPolicyName;
#if MODULAR
if (this.FirewallPolicyName == null && ParameterWasBound(nameof(this.FirewallPolicyName)))
{
WriteWarning("You are passing $null as a value for parameter FirewallPolicyName 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.Tag != null)
{
context.Tag = new List(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.NetworkFirewall.Model.CreateFirewallPolicyRequest();
if (cmdletContext.Description != null)
{
request.Description = cmdletContext.Description;
}
if (cmdletContext.DryRun != null)
{
request.DryRun = cmdletContext.DryRun.Value;
}
// populate EncryptionConfiguration
var requestEncryptionConfigurationIsNull = true;
request.EncryptionConfiguration = new Amazon.NetworkFirewall.Model.EncryptionConfiguration();
System.String requestEncryptionConfiguration_encryptionConfiguration_KeyId = null;
if (cmdletContext.EncryptionConfiguration_KeyId != null)
{
requestEncryptionConfiguration_encryptionConfiguration_KeyId = cmdletContext.EncryptionConfiguration_KeyId;
}
if (requestEncryptionConfiguration_encryptionConfiguration_KeyId != null)
{
request.EncryptionConfiguration.KeyId = requestEncryptionConfiguration_encryptionConfiguration_KeyId;
requestEncryptionConfigurationIsNull = false;
}
Amazon.NetworkFirewall.EncryptionType requestEncryptionConfiguration_encryptionConfiguration_Type = null;
if (cmdletContext.EncryptionConfiguration_Type != null)
{
requestEncryptionConfiguration_encryptionConfiguration_Type = cmdletContext.EncryptionConfiguration_Type;
}
if (requestEncryptionConfiguration_encryptionConfiguration_Type != null)
{
request.EncryptionConfiguration.Type = requestEncryptionConfiguration_encryptionConfiguration_Type;
requestEncryptionConfigurationIsNull = false;
}
// determine if request.EncryptionConfiguration should be set to null
if (requestEncryptionConfigurationIsNull)
{
request.EncryptionConfiguration = null;
}
// populate FirewallPolicy
var requestFirewallPolicyIsNull = true;
request.FirewallPolicy = new Amazon.NetworkFirewall.Model.FirewallPolicy();
List requestFirewallPolicy_firewallPolicy_StatefulDefaultAction = null;
if (cmdletContext.FirewallPolicy_StatefulDefaultAction != null)
{
requestFirewallPolicy_firewallPolicy_StatefulDefaultAction = cmdletContext.FirewallPolicy_StatefulDefaultAction;
}
if (requestFirewallPolicy_firewallPolicy_StatefulDefaultAction != null)
{
request.FirewallPolicy.StatefulDefaultActions = requestFirewallPolicy_firewallPolicy_StatefulDefaultAction;
requestFirewallPolicyIsNull = false;
}
List requestFirewallPolicy_firewallPolicy_StatefulRuleGroupReference = null;
if (cmdletContext.FirewallPolicy_StatefulRuleGroupReference != null)
{
requestFirewallPolicy_firewallPolicy_StatefulRuleGroupReference = cmdletContext.FirewallPolicy_StatefulRuleGroupReference;
}
if (requestFirewallPolicy_firewallPolicy_StatefulRuleGroupReference != null)
{
request.FirewallPolicy.StatefulRuleGroupReferences = requestFirewallPolicy_firewallPolicy_StatefulRuleGroupReference;
requestFirewallPolicyIsNull = false;
}
List requestFirewallPolicy_firewallPolicy_StatelessCustomAction = null;
if (cmdletContext.FirewallPolicy_StatelessCustomAction != null)
{
requestFirewallPolicy_firewallPolicy_StatelessCustomAction = cmdletContext.FirewallPolicy_StatelessCustomAction;
}
if (requestFirewallPolicy_firewallPolicy_StatelessCustomAction != null)
{
request.FirewallPolicy.StatelessCustomActions = requestFirewallPolicy_firewallPolicy_StatelessCustomAction;
requestFirewallPolicyIsNull = false;
}
List requestFirewallPolicy_firewallPolicy_StatelessDefaultAction = null;
if (cmdletContext.FirewallPolicy_StatelessDefaultAction != null)
{
requestFirewallPolicy_firewallPolicy_StatelessDefaultAction = cmdletContext.FirewallPolicy_StatelessDefaultAction;
}
if (requestFirewallPolicy_firewallPolicy_StatelessDefaultAction != null)
{
request.FirewallPolicy.StatelessDefaultActions = requestFirewallPolicy_firewallPolicy_StatelessDefaultAction;
requestFirewallPolicyIsNull = false;
}
List requestFirewallPolicy_firewallPolicy_StatelessFragmentDefaultAction = null;
if (cmdletContext.FirewallPolicy_StatelessFragmentDefaultAction != null)
{
requestFirewallPolicy_firewallPolicy_StatelessFragmentDefaultAction = cmdletContext.FirewallPolicy_StatelessFragmentDefaultAction;
}
if (requestFirewallPolicy_firewallPolicy_StatelessFragmentDefaultAction != null)
{
request.FirewallPolicy.StatelessFragmentDefaultActions = requestFirewallPolicy_firewallPolicy_StatelessFragmentDefaultAction;
requestFirewallPolicyIsNull = false;
}
List requestFirewallPolicy_firewallPolicy_StatelessRuleGroupReference = null;
if (cmdletContext.FirewallPolicy_StatelessRuleGroupReference != null)
{
requestFirewallPolicy_firewallPolicy_StatelessRuleGroupReference = cmdletContext.FirewallPolicy_StatelessRuleGroupReference;
}
if (requestFirewallPolicy_firewallPolicy_StatelessRuleGroupReference != null)
{
request.FirewallPolicy.StatelessRuleGroupReferences = requestFirewallPolicy_firewallPolicy_StatelessRuleGroupReference;
requestFirewallPolicyIsNull = false;
}
System.String requestFirewallPolicy_firewallPolicy_TLSInspectionConfigurationArn = null;
if (cmdletContext.FirewallPolicy_TLSInspectionConfigurationArn != null)
{
requestFirewallPolicy_firewallPolicy_TLSInspectionConfigurationArn = cmdletContext.FirewallPolicy_TLSInspectionConfigurationArn;
}
if (requestFirewallPolicy_firewallPolicy_TLSInspectionConfigurationArn != null)
{
request.FirewallPolicy.TLSInspectionConfigurationArn = requestFirewallPolicy_firewallPolicy_TLSInspectionConfigurationArn;
requestFirewallPolicyIsNull = false;
}
Amazon.NetworkFirewall.Model.PolicyVariables requestFirewallPolicy_firewallPolicy_PolicyVariables = null;
// populate PolicyVariables
var requestFirewallPolicy_firewallPolicy_PolicyVariablesIsNull = true;
requestFirewallPolicy_firewallPolicy_PolicyVariables = new Amazon.NetworkFirewall.Model.PolicyVariables();
Dictionary requestFirewallPolicy_firewallPolicy_PolicyVariables_policyVariables_RuleVariable = null;
if (cmdletContext.PolicyVariables_RuleVariable != null)
{
requestFirewallPolicy_firewallPolicy_PolicyVariables_policyVariables_RuleVariable = cmdletContext.PolicyVariables_RuleVariable;
}
if (requestFirewallPolicy_firewallPolicy_PolicyVariables_policyVariables_RuleVariable != null)
{
requestFirewallPolicy_firewallPolicy_PolicyVariables.RuleVariables = requestFirewallPolicy_firewallPolicy_PolicyVariables_policyVariables_RuleVariable;
requestFirewallPolicy_firewallPolicy_PolicyVariablesIsNull = false;
}
// determine if requestFirewallPolicy_firewallPolicy_PolicyVariables should be set to null
if (requestFirewallPolicy_firewallPolicy_PolicyVariablesIsNull)
{
requestFirewallPolicy_firewallPolicy_PolicyVariables = null;
}
if (requestFirewallPolicy_firewallPolicy_PolicyVariables != null)
{
request.FirewallPolicy.PolicyVariables = requestFirewallPolicy_firewallPolicy_PolicyVariables;
requestFirewallPolicyIsNull = false;
}
Amazon.NetworkFirewall.Model.StatefulEngineOptions requestFirewallPolicy_firewallPolicy_StatefulEngineOptions = null;
// populate StatefulEngineOptions
var requestFirewallPolicy_firewallPolicy_StatefulEngineOptionsIsNull = true;
requestFirewallPolicy_firewallPolicy_StatefulEngineOptions = new Amazon.NetworkFirewall.Model.StatefulEngineOptions();
Amazon.NetworkFirewall.RuleOrder requestFirewallPolicy_firewallPolicy_StatefulEngineOptions_statefulEngineOptions_RuleOrder = null;
if (cmdletContext.StatefulEngineOptions_RuleOrder != null)
{
requestFirewallPolicy_firewallPolicy_StatefulEngineOptions_statefulEngineOptions_RuleOrder = cmdletContext.StatefulEngineOptions_RuleOrder;
}
if (requestFirewallPolicy_firewallPolicy_StatefulEngineOptions_statefulEngineOptions_RuleOrder != null)
{
requestFirewallPolicy_firewallPolicy_StatefulEngineOptions.RuleOrder = requestFirewallPolicy_firewallPolicy_StatefulEngineOptions_statefulEngineOptions_RuleOrder;
requestFirewallPolicy_firewallPolicy_StatefulEngineOptionsIsNull = false;
}
Amazon.NetworkFirewall.StreamExceptionPolicy requestFirewallPolicy_firewallPolicy_StatefulEngineOptions_statefulEngineOptions_StreamExceptionPolicy = null;
if (cmdletContext.StatefulEngineOptions_StreamExceptionPolicy != null)
{
requestFirewallPolicy_firewallPolicy_StatefulEngineOptions_statefulEngineOptions_StreamExceptionPolicy = cmdletContext.StatefulEngineOptions_StreamExceptionPolicy;
}
if (requestFirewallPolicy_firewallPolicy_StatefulEngineOptions_statefulEngineOptions_StreamExceptionPolicy != null)
{
requestFirewallPolicy_firewallPolicy_StatefulEngineOptions.StreamExceptionPolicy = requestFirewallPolicy_firewallPolicy_StatefulEngineOptions_statefulEngineOptions_StreamExceptionPolicy;
requestFirewallPolicy_firewallPolicy_StatefulEngineOptionsIsNull = false;
}
// determine if requestFirewallPolicy_firewallPolicy_StatefulEngineOptions should be set to null
if (requestFirewallPolicy_firewallPolicy_StatefulEngineOptionsIsNull)
{
requestFirewallPolicy_firewallPolicy_StatefulEngineOptions = null;
}
if (requestFirewallPolicy_firewallPolicy_StatefulEngineOptions != null)
{
request.FirewallPolicy.StatefulEngineOptions = requestFirewallPolicy_firewallPolicy_StatefulEngineOptions;
requestFirewallPolicyIsNull = false;
}
// determine if request.FirewallPolicy should be set to null
if (requestFirewallPolicyIsNull)
{
request.FirewallPolicy = null;
}
if (cmdletContext.FirewallPolicyName != null)
{
request.FirewallPolicyName = cmdletContext.FirewallPolicyName;
}
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.NetworkFirewall.Model.CreateFirewallPolicyResponse CallAWSServiceOperation(IAmazonNetworkFirewall client, Amazon.NetworkFirewall.Model.CreateFirewallPolicyRequest request)
{
Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Network Firewall", "CreateFirewallPolicy");
try
{
#if DESKTOP
return client.CreateFirewallPolicy(request);
#elif CORECLR
return client.CreateFirewallPolicyAsync(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 Description { get; set; }
public System.Boolean? DryRun { get; set; }
public System.String EncryptionConfiguration_KeyId { get; set; }
public Amazon.NetworkFirewall.EncryptionType EncryptionConfiguration_Type { get; set; }
public Dictionary PolicyVariables_RuleVariable { get; set; }
public List FirewallPolicy_StatefulDefaultAction { get; set; }
public Amazon.NetworkFirewall.RuleOrder StatefulEngineOptions_RuleOrder { get; set; }
public Amazon.NetworkFirewall.StreamExceptionPolicy StatefulEngineOptions_StreamExceptionPolicy { get; set; }
public List FirewallPolicy_StatefulRuleGroupReference { get; set; }
public List FirewallPolicy_StatelessCustomAction { get; set; }
public List FirewallPolicy_StatelessDefaultAction { get; set; }
public List FirewallPolicy_StatelessFragmentDefaultAction { get; set; }
public List FirewallPolicy_StatelessRuleGroupReference { get; set; }
public System.String FirewallPolicy_TLSInspectionConfigurationArn { get; set; }
public System.String FirewallPolicyName { get; set; }
public List Tag { get; set; }
public System.Func Select { get; set; } =
(response, cmdlet) => response;
}
}
}