Ejemplo n.º 1
0
 private Amazon.NetworkFirewall.Model.CreateRuleGroupResponse CallAWSServiceOperation(IAmazonNetworkFirewall client, Amazon.NetworkFirewall.Model.CreateRuleGroupRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Network Firewall", "CreateRuleGroup");
     try
     {
         #if DESKTOP
         return(client.CreateRuleGroup(request));
         #elif CORECLR
         return(client.CreateRuleGroupAsync(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;
     }
 }
Ejemplo n.º 2
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);
        }