Esempio n. 1
0
 private Amazon.WAFV2.Model.CreateWebACLResponse CallAWSServiceOperation(IAmazonWAFV2 client, Amazon.WAFV2.Model.CreateWebACLRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS WAF V2", "CreateWebACL");
     try
     {
         #if DESKTOP
         return(client.CreateWebACL(request));
         #elif CORECLR
         return(client.CreateWebACLAsync(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;
     }
 }
Esempio n. 2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.WAFV2.Model.CreateWebACLRequest();


            // populate DefaultAction
            var requestDefaultActionIsNull = true;

            request.DefaultAction = new Amazon.WAFV2.Model.DefaultAction();
            Amazon.WAFV2.Model.AllowAction requestDefaultAction_defaultAction_Allow = null;
            if (cmdletContext.DefaultAction_Allow != null)
            {
                requestDefaultAction_defaultAction_Allow = cmdletContext.DefaultAction_Allow;
            }
            if (requestDefaultAction_defaultAction_Allow != null)
            {
                request.DefaultAction.Allow = requestDefaultAction_defaultAction_Allow;
                requestDefaultActionIsNull  = false;
            }
            Amazon.WAFV2.Model.BlockAction requestDefaultAction_defaultAction_Block = null;
            if (cmdletContext.DefaultAction_Block != null)
            {
                requestDefaultAction_defaultAction_Block = cmdletContext.DefaultAction_Block;
            }
            if (requestDefaultAction_defaultAction_Block != null)
            {
                request.DefaultAction.Block = requestDefaultAction_defaultAction_Block;
                requestDefaultActionIsNull  = false;
            }
            // determine if request.DefaultAction should be set to null
            if (requestDefaultActionIsNull)
            {
                request.DefaultAction = null;
            }
            if (cmdletContext.Description != null)
            {
                request.Description = cmdletContext.Description;
            }
            if (cmdletContext.Name != null)
            {
                request.Name = cmdletContext.Name;
            }
            if (cmdletContext.Rule != null)
            {
                request.Rules = cmdletContext.Rule;
            }
            if (cmdletContext.Scope != null)
            {
                request.Scope = cmdletContext.Scope;
            }
            if (cmdletContext.Tag != null)
            {
                request.Tags = cmdletContext.Tag;
            }

            // populate VisibilityConfig
            var requestVisibilityConfigIsNull = true;

            request.VisibilityConfig = new Amazon.WAFV2.Model.VisibilityConfig();
            System.Boolean?requestVisibilityConfig_visibilityConfig_CloudWatchMetricsEnabled = null;
            if (cmdletContext.VisibilityConfig_CloudWatchMetricsEnabled != null)
            {
                requestVisibilityConfig_visibilityConfig_CloudWatchMetricsEnabled = cmdletContext.VisibilityConfig_CloudWatchMetricsEnabled.Value;
            }
            if (requestVisibilityConfig_visibilityConfig_CloudWatchMetricsEnabled != null)
            {
                request.VisibilityConfig.CloudWatchMetricsEnabled = requestVisibilityConfig_visibilityConfig_CloudWatchMetricsEnabled.Value;
                requestVisibilityConfigIsNull = false;
            }
            System.String requestVisibilityConfig_visibilityConfig_MetricName = null;
            if (cmdletContext.VisibilityConfig_MetricName != null)
            {
                requestVisibilityConfig_visibilityConfig_MetricName = cmdletContext.VisibilityConfig_MetricName;
            }
            if (requestVisibilityConfig_visibilityConfig_MetricName != null)
            {
                request.VisibilityConfig.MetricName = requestVisibilityConfig_visibilityConfig_MetricName;
                requestVisibilityConfigIsNull       = false;
            }
            System.Boolean?requestVisibilityConfig_visibilityConfig_SampledRequestsEnabled = null;
            if (cmdletContext.VisibilityConfig_SampledRequestsEnabled != null)
            {
                requestVisibilityConfig_visibilityConfig_SampledRequestsEnabled = cmdletContext.VisibilityConfig_SampledRequestsEnabled.Value;
            }
            if (requestVisibilityConfig_visibilityConfig_SampledRequestsEnabled != null)
            {
                request.VisibilityConfig.SampledRequestsEnabled = requestVisibilityConfig_visibilityConfig_SampledRequestsEnabled.Value;
                requestVisibilityConfigIsNull = false;
            }
            // determine if request.VisibilityConfig should be set to null
            if (requestVisibilityConfigIsNull)
            {
                request.VisibilityConfig = null;
            }

            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);
        }