示例#1
0
 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;
     }
 }
示例#2
0
        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 <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;
            }
            // 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);
        }