Пример #1
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.NetworkFirewall.Model.CreateRuleGroupRequest();

            if (cmdletContext.Capacity != null)
            {
                request.Capacity = cmdletContext.Capacity.Value;
            }
            if (cmdletContext.Description != null)
            {
                request.Description = cmdletContext.Description;
            }
            if (cmdletContext.DryRun != null)
            {
                request.DryRun = cmdletContext.DryRun.Value;
            }

            // populate RuleGroup
            var requestRuleGroupIsNull = true;

            request.RuleGroup = new Amazon.NetworkFirewall.Model.RuleGroup();
            Amazon.NetworkFirewall.Model.StatefulRuleOptions requestRuleGroup_ruleGroup_StatefulRuleOptions = null;

            // populate StatefulRuleOptions
            var requestRuleGroup_ruleGroup_StatefulRuleOptionsIsNull = true;

            requestRuleGroup_ruleGroup_StatefulRuleOptions = new Amazon.NetworkFirewall.Model.StatefulRuleOptions();
            Amazon.NetworkFirewall.RuleOrder requestRuleGroup_ruleGroup_StatefulRuleOptions_statefulRuleOptions_RuleOrder = null;
            if (cmdletContext.StatefulRuleOptions_RuleOrder != null)
            {
                requestRuleGroup_ruleGroup_StatefulRuleOptions_statefulRuleOptions_RuleOrder = cmdletContext.StatefulRuleOptions_RuleOrder;
            }
            if (requestRuleGroup_ruleGroup_StatefulRuleOptions_statefulRuleOptions_RuleOrder != null)
            {
                requestRuleGroup_ruleGroup_StatefulRuleOptions.RuleOrder = requestRuleGroup_ruleGroup_StatefulRuleOptions_statefulRuleOptions_RuleOrder;
                requestRuleGroup_ruleGroup_StatefulRuleOptionsIsNull     = false;
            }
            // determine if requestRuleGroup_ruleGroup_StatefulRuleOptions should be set to null
            if (requestRuleGroup_ruleGroup_StatefulRuleOptionsIsNull)
            {
                requestRuleGroup_ruleGroup_StatefulRuleOptions = null;
            }
            if (requestRuleGroup_ruleGroup_StatefulRuleOptions != null)
            {
                request.RuleGroup.StatefulRuleOptions = requestRuleGroup_ruleGroup_StatefulRuleOptions;
                requestRuleGroupIsNull = false;
            }
            Amazon.NetworkFirewall.Model.RuleVariables requestRuleGroup_ruleGroup_RuleVariables = null;

            // populate RuleVariables
            var requestRuleGroup_ruleGroup_RuleVariablesIsNull = true;

            requestRuleGroup_ruleGroup_RuleVariables = new Amazon.NetworkFirewall.Model.RuleVariables();
            Dictionary <System.String, Amazon.NetworkFirewall.Model.IPSet> requestRuleGroup_ruleGroup_RuleVariables_ruleVariables_IPSet = null;

            if (cmdletContext.RuleVariables_IPSet != null)
            {
                requestRuleGroup_ruleGroup_RuleVariables_ruleVariables_IPSet = cmdletContext.RuleVariables_IPSet;
            }
            if (requestRuleGroup_ruleGroup_RuleVariables_ruleVariables_IPSet != null)
            {
                requestRuleGroup_ruleGroup_RuleVariables.IPSets = requestRuleGroup_ruleGroup_RuleVariables_ruleVariables_IPSet;
                requestRuleGroup_ruleGroup_RuleVariablesIsNull  = false;
            }
            Dictionary <System.String, Amazon.NetworkFirewall.Model.PortSet> requestRuleGroup_ruleGroup_RuleVariables_ruleVariables_PortSet = null;

            if (cmdletContext.RuleVariables_PortSet != null)
            {
                requestRuleGroup_ruleGroup_RuleVariables_ruleVariables_PortSet = cmdletContext.RuleVariables_PortSet;
            }
            if (requestRuleGroup_ruleGroup_RuleVariables_ruleVariables_PortSet != null)
            {
                requestRuleGroup_ruleGroup_RuleVariables.PortSets = requestRuleGroup_ruleGroup_RuleVariables_ruleVariables_PortSet;
                requestRuleGroup_ruleGroup_RuleVariablesIsNull    = false;
            }
            // determine if requestRuleGroup_ruleGroup_RuleVariables should be set to null
            if (requestRuleGroup_ruleGroup_RuleVariablesIsNull)
            {
                requestRuleGroup_ruleGroup_RuleVariables = null;
            }
            if (requestRuleGroup_ruleGroup_RuleVariables != null)
            {
                request.RuleGroup.RuleVariables = requestRuleGroup_ruleGroup_RuleVariables;
                requestRuleGroupIsNull          = false;
            }
            Amazon.NetworkFirewall.Model.RulesSource requestRuleGroup_ruleGroup_RulesSource = null;

            // populate RulesSource
            var requestRuleGroup_ruleGroup_RulesSourceIsNull = true;

            requestRuleGroup_ruleGroup_RulesSource = new Amazon.NetworkFirewall.Model.RulesSource();
            System.String requestRuleGroup_ruleGroup_RulesSource_rulesSource_RulesString = null;
            if (cmdletContext.RulesSource_RulesString != null)
            {
                requestRuleGroup_ruleGroup_RulesSource_rulesSource_RulesString = cmdletContext.RulesSource_RulesString;
            }
            if (requestRuleGroup_ruleGroup_RulesSource_rulesSource_RulesString != null)
            {
                requestRuleGroup_ruleGroup_RulesSource.RulesString = requestRuleGroup_ruleGroup_RulesSource_rulesSource_RulesString;
                requestRuleGroup_ruleGroup_RulesSourceIsNull       = false;
            }
            List <Amazon.NetworkFirewall.Model.StatefulRule> requestRuleGroup_ruleGroup_RulesSource_rulesSource_StatefulRule = null;

            if (cmdletContext.RulesSource_StatefulRule != null)
            {
                requestRuleGroup_ruleGroup_RulesSource_rulesSource_StatefulRule = cmdletContext.RulesSource_StatefulRule;
            }
            if (requestRuleGroup_ruleGroup_RulesSource_rulesSource_StatefulRule != null)
            {
                requestRuleGroup_ruleGroup_RulesSource.StatefulRules = requestRuleGroup_ruleGroup_RulesSource_rulesSource_StatefulRule;
                requestRuleGroup_ruleGroup_RulesSourceIsNull         = false;
            }
            Amazon.NetworkFirewall.Model.StatelessRulesAndCustomActions requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActions = null;

            // populate StatelessRulesAndCustomActions
            var requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActionsIsNull = true;

            requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActions = new Amazon.NetworkFirewall.Model.StatelessRulesAndCustomActions();
            List <Amazon.NetworkFirewall.Model.CustomAction> requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActions_statelessRulesAndCustomActions_CustomAction = null;

            if (cmdletContext.StatelessRulesAndCustomActions_CustomAction != null)
            {
                requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActions_statelessRulesAndCustomActions_CustomAction = cmdletContext.StatelessRulesAndCustomActions_CustomAction;
            }
            if (requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActions_statelessRulesAndCustomActions_CustomAction != null)
            {
                requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActions.CustomActions = requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActions_statelessRulesAndCustomActions_CustomAction;
                requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActionsIsNull         = false;
            }
            List <Amazon.NetworkFirewall.Model.StatelessRule> requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActions_statelessRulesAndCustomActions_StatelessRule = null;

            if (cmdletContext.StatelessRulesAndCustomActions_StatelessRule != null)
            {
                requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActions_statelessRulesAndCustomActions_StatelessRule = cmdletContext.StatelessRulesAndCustomActions_StatelessRule;
            }
            if (requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActions_statelessRulesAndCustomActions_StatelessRule != null)
            {
                requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActions.StatelessRules = requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActions_statelessRulesAndCustomActions_StatelessRule;
                requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActionsIsNull          = false;
            }
            // determine if requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActions should be set to null
            if (requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActionsIsNull)
            {
                requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActions = null;
            }
            if (requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActions != null)
            {
                requestRuleGroup_ruleGroup_RulesSource.StatelessRulesAndCustomActions = requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_StatelessRulesAndCustomActions;
                requestRuleGroup_ruleGroup_RulesSourceIsNull = false;
            }
            Amazon.NetworkFirewall.Model.RulesSourceList requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList = null;

            // populate RulesSourceList
            var requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceListIsNull = true;

            requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList = new Amazon.NetworkFirewall.Model.RulesSourceList();
            Amazon.NetworkFirewall.GeneratedRulesType requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList_rulesSourceList_GeneratedRulesType = null;
            if (cmdletContext.RulesSourceList_GeneratedRulesType != null)
            {
                requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList_rulesSourceList_GeneratedRulesType = cmdletContext.RulesSourceList_GeneratedRulesType;
            }
            if (requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList_rulesSourceList_GeneratedRulesType != null)
            {
                requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList.GeneratedRulesType = requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList_rulesSourceList_GeneratedRulesType;
                requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceListIsNull = false;
            }
            List <System.String> requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList_rulesSourceList_Target = null;

            if (cmdletContext.RulesSourceList_Target != null)
            {
                requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList_rulesSourceList_Target = cmdletContext.RulesSourceList_Target;
            }
            if (requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList_rulesSourceList_Target != null)
            {
                requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList.Targets = requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList_rulesSourceList_Target;
                requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceListIsNull   = false;
            }
            List <System.String> requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList_rulesSourceList_TargetType = null;

            if (cmdletContext.RulesSourceList_TargetType != null)
            {
                requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList_rulesSourceList_TargetType = cmdletContext.RulesSourceList_TargetType;
            }
            if (requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList_rulesSourceList_TargetType != null)
            {
                requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList.TargetTypes = requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList_rulesSourceList_TargetType;
                requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceListIsNull       = false;
            }
            // determine if requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList should be set to null
            if (requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceListIsNull)
            {
                requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList = null;
            }
            if (requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList != null)
            {
                requestRuleGroup_ruleGroup_RulesSource.RulesSourceList = requestRuleGroup_ruleGroup_RulesSource_ruleGroup_RulesSource_RulesSourceList;
                requestRuleGroup_ruleGroup_RulesSourceIsNull           = false;
            }
            // determine if requestRuleGroup_ruleGroup_RulesSource should be set to null
            if (requestRuleGroup_ruleGroup_RulesSourceIsNull)
            {
                requestRuleGroup_ruleGroup_RulesSource = null;
            }
            if (requestRuleGroup_ruleGroup_RulesSource != null)
            {
                request.RuleGroup.RulesSource = requestRuleGroup_ruleGroup_RulesSource;
                requestRuleGroupIsNull        = false;
            }
            // determine if request.RuleGroup should be set to null
            if (requestRuleGroupIsNull)
            {
                request.RuleGroup = null;
            }
            if (cmdletContext.RuleGroupName != null)
            {
                request.RuleGroupName = cmdletContext.RuleGroupName;
            }
            if (cmdletContext.Rule != null)
            {
                request.Rules = cmdletContext.Rule;
            }
            if (cmdletContext.Tag != null)
            {
                request.Tags = cmdletContext.Tag;
            }
            if (cmdletContext.Type != null)
            {
                request.Type = cmdletContext.Type;
            }

            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 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 FirewallPolicy
            var requestFirewallPolicyIsNull = true;

            request.FirewallPolicy = new Amazon.NetworkFirewall.Model.FirewallPolicy();
            List <System.String> 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 <Amazon.NetworkFirewall.Model.StatefulRuleGroupReference> 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 <Amazon.NetworkFirewall.Model.CustomAction> 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 <System.String> 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 <System.String> 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 <Amazon.NetworkFirewall.Model.StatelessRuleGroupReference> 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;
            }
            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;
            }
            // 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);
        }