private Amazon.EC2.Model.CreateTrafficMirrorFilterRuleResponse CallAWSServiceOperation(IAmazonEC2 client, Amazon.EC2.Model.CreateTrafficMirrorFilterRuleRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Elastic Compute Cloud (EC2)", "CreateTrafficMirrorFilterRule");
     try
     {
         #if DESKTOP
         return(client.CreateTrafficMirrorFilterRule(request));
         #elif CORECLR
         return(client.CreateTrafficMirrorFilterRuleAsync(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;
     }
 }
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.EC2.Model.CreateTrafficMirrorFilterRuleRequest();

            if (cmdletContext.ClientToken != null)
            {
                request.ClientToken = cmdletContext.ClientToken;
            }
            if (cmdletContext.Description != null)
            {
                request.Description = cmdletContext.Description;
            }
            if (cmdletContext.DestinationCidrBlock != null)
            {
                request.DestinationCidrBlock = cmdletContext.DestinationCidrBlock;
            }

            // populate DestinationPortRange
            var requestDestinationPortRangeIsNull = true;

            request.DestinationPortRange = new Amazon.EC2.Model.TrafficMirrorPortRangeRequest();
            System.Int32?requestDestinationPortRange_destinationPortRange_FromPort = null;
            if (cmdletContext.DestinationPortRange_FromPort != null)
            {
                requestDestinationPortRange_destinationPortRange_FromPort = cmdletContext.DestinationPortRange_FromPort.Value;
            }
            if (requestDestinationPortRange_destinationPortRange_FromPort != null)
            {
                request.DestinationPortRange.FromPort = requestDestinationPortRange_destinationPortRange_FromPort.Value;
                requestDestinationPortRangeIsNull     = false;
            }
            System.Int32?requestDestinationPortRange_destinationPortRange_ToPort = null;
            if (cmdletContext.DestinationPortRange_ToPort != null)
            {
                requestDestinationPortRange_destinationPortRange_ToPort = cmdletContext.DestinationPortRange_ToPort.Value;
            }
            if (requestDestinationPortRange_destinationPortRange_ToPort != null)
            {
                request.DestinationPortRange.ToPort = requestDestinationPortRange_destinationPortRange_ToPort.Value;
                requestDestinationPortRangeIsNull   = false;
            }
            // determine if request.DestinationPortRange should be set to null
            if (requestDestinationPortRangeIsNull)
            {
                request.DestinationPortRange = null;
            }
            if (cmdletContext.Protocol != null)
            {
                request.Protocol = cmdletContext.Protocol.Value;
            }
            if (cmdletContext.RuleAction != null)
            {
                request.RuleAction = cmdletContext.RuleAction;
            }
            if (cmdletContext.RuleNumber != null)
            {
                request.RuleNumber = cmdletContext.RuleNumber.Value;
            }
            if (cmdletContext.SourceCidrBlock != null)
            {
                request.SourceCidrBlock = cmdletContext.SourceCidrBlock;
            }

            // populate SourcePortRange
            var requestSourcePortRangeIsNull = true;

            request.SourcePortRange = new Amazon.EC2.Model.TrafficMirrorPortRangeRequest();
            System.Int32?requestSourcePortRange_sourcePortRange_FromPort = null;
            if (cmdletContext.SourcePortRange_FromPort != null)
            {
                requestSourcePortRange_sourcePortRange_FromPort = cmdletContext.SourcePortRange_FromPort.Value;
            }
            if (requestSourcePortRange_sourcePortRange_FromPort != null)
            {
                request.SourcePortRange.FromPort = requestSourcePortRange_sourcePortRange_FromPort.Value;
                requestSourcePortRangeIsNull     = false;
            }
            System.Int32?requestSourcePortRange_sourcePortRange_ToPort = null;
            if (cmdletContext.SourcePortRange_ToPort != null)
            {
                requestSourcePortRange_sourcePortRange_ToPort = cmdletContext.SourcePortRange_ToPort.Value;
            }
            if (requestSourcePortRange_sourcePortRange_ToPort != null)
            {
                request.SourcePortRange.ToPort = requestSourcePortRange_sourcePortRange_ToPort.Value;
                requestSourcePortRangeIsNull   = false;
            }
            // determine if request.SourcePortRange should be set to null
            if (requestSourcePortRangeIsNull)
            {
                request.SourcePortRange = null;
            }
            if (cmdletContext.TrafficDirection != null)
            {
                request.TrafficDirection = cmdletContext.TrafficDirection;
            }
            if (cmdletContext.TrafficMirrorFilterId != null)
            {
                request.TrafficMirrorFilterId = cmdletContext.TrafficMirrorFilterId;
            }

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