Пример #1
0
 private Amazon.Route53RecoveryControlConfig.Model.CreateSafetyRuleResponse CallAWSServiceOperation(IAmazonRoute53RecoveryControlConfig client, Amazon.Route53RecoveryControlConfig.Model.CreateSafetyRuleRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Route53 Recovery Control Config", "CreateSafetyRule");
     try
     {
         #if DESKTOP
         return(client.CreateSafetyRule(request));
         #elif CORECLR
         return(client.CreateSafetyRuleAsync(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.Route53RecoveryControlConfig.Model.CreateSafetyRuleRequest();


            // populate AssertionRule
            var requestAssertionRuleIsNull = true;

            request.AssertionRule = new Amazon.Route53RecoveryControlConfig.Model.NewAssertionRule();
            List <System.String> requestAssertionRule_assertionRule_AssertedControl = null;

            if (cmdletContext.AssertionRule_AssertedControl != null)
            {
                requestAssertionRule_assertionRule_AssertedControl = cmdletContext.AssertionRule_AssertedControl;
            }
            if (requestAssertionRule_assertionRule_AssertedControl != null)
            {
                request.AssertionRule.AssertedControls = requestAssertionRule_assertionRule_AssertedControl;
                requestAssertionRuleIsNull             = false;
            }
            System.String requestAssertionRule_assertionRule_ControlPanelArn = null;
            if (cmdletContext.AssertionRule_ControlPanelArn != null)
            {
                requestAssertionRule_assertionRule_ControlPanelArn = cmdletContext.AssertionRule_ControlPanelArn;
            }
            if (requestAssertionRule_assertionRule_ControlPanelArn != null)
            {
                request.AssertionRule.ControlPanelArn = requestAssertionRule_assertionRule_ControlPanelArn;
                requestAssertionRuleIsNull            = false;
            }
            System.String requestAssertionRule_assertionRule_Name = null;
            if (cmdletContext.AssertionRule_Name != null)
            {
                requestAssertionRule_assertionRule_Name = cmdletContext.AssertionRule_Name;
            }
            if (requestAssertionRule_assertionRule_Name != null)
            {
                request.AssertionRule.Name = requestAssertionRule_assertionRule_Name;
                requestAssertionRuleIsNull = false;
            }
            System.Int32?requestAssertionRule_assertionRule_WaitPeriodMs = null;
            if (cmdletContext.AssertionRule_WaitPeriodMs != null)
            {
                requestAssertionRule_assertionRule_WaitPeriodMs = cmdletContext.AssertionRule_WaitPeriodMs.Value;
            }
            if (requestAssertionRule_assertionRule_WaitPeriodMs != null)
            {
                request.AssertionRule.WaitPeriodMs = requestAssertionRule_assertionRule_WaitPeriodMs.Value;
                requestAssertionRuleIsNull         = false;
            }
            Amazon.Route53RecoveryControlConfig.Model.RuleConfig requestAssertionRule_assertionRule_RuleConfig = null;

            // populate RuleConfig
            var requestAssertionRule_assertionRule_RuleConfigIsNull = true;

            requestAssertionRule_assertionRule_RuleConfig = new Amazon.Route53RecoveryControlConfig.Model.RuleConfig();
            System.Boolean?requestAssertionRule_assertionRule_RuleConfig_assertionRule_RuleConfig_Inverted = null;
            if (cmdletContext.AssertionRule_RuleConfig_Inverted != null)
            {
                requestAssertionRule_assertionRule_RuleConfig_assertionRule_RuleConfig_Inverted = cmdletContext.AssertionRule_RuleConfig_Inverted.Value;
            }
            if (requestAssertionRule_assertionRule_RuleConfig_assertionRule_RuleConfig_Inverted != null)
            {
                requestAssertionRule_assertionRule_RuleConfig.Inverted = requestAssertionRule_assertionRule_RuleConfig_assertionRule_RuleConfig_Inverted.Value;
                requestAssertionRule_assertionRule_RuleConfigIsNull    = false;
            }
            System.Int32?requestAssertionRule_assertionRule_RuleConfig_assertionRule_RuleConfig_Threshold = null;
            if (cmdletContext.AssertionRule_RuleConfig_Threshold != null)
            {
                requestAssertionRule_assertionRule_RuleConfig_assertionRule_RuleConfig_Threshold = cmdletContext.AssertionRule_RuleConfig_Threshold.Value;
            }
            if (requestAssertionRule_assertionRule_RuleConfig_assertionRule_RuleConfig_Threshold != null)
            {
                requestAssertionRule_assertionRule_RuleConfig.Threshold = requestAssertionRule_assertionRule_RuleConfig_assertionRule_RuleConfig_Threshold.Value;
                requestAssertionRule_assertionRule_RuleConfigIsNull     = false;
            }
            Amazon.Route53RecoveryControlConfig.RuleType requestAssertionRule_assertionRule_RuleConfig_assertionRule_RuleConfig_Type = null;
            if (cmdletContext.AssertionRule_RuleConfig_Type != null)
            {
                requestAssertionRule_assertionRule_RuleConfig_assertionRule_RuleConfig_Type = cmdletContext.AssertionRule_RuleConfig_Type;
            }
            if (requestAssertionRule_assertionRule_RuleConfig_assertionRule_RuleConfig_Type != null)
            {
                requestAssertionRule_assertionRule_RuleConfig.Type  = requestAssertionRule_assertionRule_RuleConfig_assertionRule_RuleConfig_Type;
                requestAssertionRule_assertionRule_RuleConfigIsNull = false;
            }
            // determine if requestAssertionRule_assertionRule_RuleConfig should be set to null
            if (requestAssertionRule_assertionRule_RuleConfigIsNull)
            {
                requestAssertionRule_assertionRule_RuleConfig = null;
            }
            if (requestAssertionRule_assertionRule_RuleConfig != null)
            {
                request.AssertionRule.RuleConfig = requestAssertionRule_assertionRule_RuleConfig;
                requestAssertionRuleIsNull       = false;
            }
            // determine if request.AssertionRule should be set to null
            if (requestAssertionRuleIsNull)
            {
                request.AssertionRule = null;
            }
            if (cmdletContext.ClientToken != null)
            {
                request.ClientToken = cmdletContext.ClientToken;
            }

            // populate GatingRule
            var requestGatingRuleIsNull = true;

            request.GatingRule = new Amazon.Route53RecoveryControlConfig.Model.NewGatingRule();
            System.String requestGatingRule_gatingRule_ControlPanelArn = null;
            if (cmdletContext.GatingRule_ControlPanelArn != null)
            {
                requestGatingRule_gatingRule_ControlPanelArn = cmdletContext.GatingRule_ControlPanelArn;
            }
            if (requestGatingRule_gatingRule_ControlPanelArn != null)
            {
                request.GatingRule.ControlPanelArn = requestGatingRule_gatingRule_ControlPanelArn;
                requestGatingRuleIsNull            = false;
            }
            List <System.String> requestGatingRule_gatingRule_GatingControl = null;

            if (cmdletContext.GatingRule_GatingControl != null)
            {
                requestGatingRule_gatingRule_GatingControl = cmdletContext.GatingRule_GatingControl;
            }
            if (requestGatingRule_gatingRule_GatingControl != null)
            {
                request.GatingRule.GatingControls = requestGatingRule_gatingRule_GatingControl;
                requestGatingRuleIsNull           = false;
            }
            System.String requestGatingRule_gatingRule_Name = null;
            if (cmdletContext.GatingRule_Name != null)
            {
                requestGatingRule_gatingRule_Name = cmdletContext.GatingRule_Name;
            }
            if (requestGatingRule_gatingRule_Name != null)
            {
                request.GatingRule.Name = requestGatingRule_gatingRule_Name;
                requestGatingRuleIsNull = false;
            }
            List <System.String> requestGatingRule_gatingRule_TargetControl = null;

            if (cmdletContext.GatingRule_TargetControl != null)
            {
                requestGatingRule_gatingRule_TargetControl = cmdletContext.GatingRule_TargetControl;
            }
            if (requestGatingRule_gatingRule_TargetControl != null)
            {
                request.GatingRule.TargetControls = requestGatingRule_gatingRule_TargetControl;
                requestGatingRuleIsNull           = false;
            }
            System.Int32?requestGatingRule_gatingRule_WaitPeriodMs = null;
            if (cmdletContext.GatingRule_WaitPeriodMs != null)
            {
                requestGatingRule_gatingRule_WaitPeriodMs = cmdletContext.GatingRule_WaitPeriodMs.Value;
            }
            if (requestGatingRule_gatingRule_WaitPeriodMs != null)
            {
                request.GatingRule.WaitPeriodMs = requestGatingRule_gatingRule_WaitPeriodMs.Value;
                requestGatingRuleIsNull         = false;
            }
            Amazon.Route53RecoveryControlConfig.Model.RuleConfig requestGatingRule_gatingRule_RuleConfig = null;

            // populate RuleConfig
            var requestGatingRule_gatingRule_RuleConfigIsNull = true;

            requestGatingRule_gatingRule_RuleConfig = new Amazon.Route53RecoveryControlConfig.Model.RuleConfig();
            System.Boolean?requestGatingRule_gatingRule_RuleConfig_gatingRule_RuleConfig_Inverted = null;
            if (cmdletContext.GatingRule_RuleConfig_Inverted != null)
            {
                requestGatingRule_gatingRule_RuleConfig_gatingRule_RuleConfig_Inverted = cmdletContext.GatingRule_RuleConfig_Inverted.Value;
            }
            if (requestGatingRule_gatingRule_RuleConfig_gatingRule_RuleConfig_Inverted != null)
            {
                requestGatingRule_gatingRule_RuleConfig.Inverted = requestGatingRule_gatingRule_RuleConfig_gatingRule_RuleConfig_Inverted.Value;
                requestGatingRule_gatingRule_RuleConfigIsNull    = false;
            }
            System.Int32?requestGatingRule_gatingRule_RuleConfig_gatingRule_RuleConfig_Threshold = null;
            if (cmdletContext.GatingRule_RuleConfig_Threshold != null)
            {
                requestGatingRule_gatingRule_RuleConfig_gatingRule_RuleConfig_Threshold = cmdletContext.GatingRule_RuleConfig_Threshold.Value;
            }
            if (requestGatingRule_gatingRule_RuleConfig_gatingRule_RuleConfig_Threshold != null)
            {
                requestGatingRule_gatingRule_RuleConfig.Threshold = requestGatingRule_gatingRule_RuleConfig_gatingRule_RuleConfig_Threshold.Value;
                requestGatingRule_gatingRule_RuleConfigIsNull     = false;
            }
            Amazon.Route53RecoveryControlConfig.RuleType requestGatingRule_gatingRule_RuleConfig_gatingRule_RuleConfig_Type = null;
            if (cmdletContext.GatingRule_RuleConfig_Type != null)
            {
                requestGatingRule_gatingRule_RuleConfig_gatingRule_RuleConfig_Type = cmdletContext.GatingRule_RuleConfig_Type;
            }
            if (requestGatingRule_gatingRule_RuleConfig_gatingRule_RuleConfig_Type != null)
            {
                requestGatingRule_gatingRule_RuleConfig.Type  = requestGatingRule_gatingRule_RuleConfig_gatingRule_RuleConfig_Type;
                requestGatingRule_gatingRule_RuleConfigIsNull = false;
            }
            // determine if requestGatingRule_gatingRule_RuleConfig should be set to null
            if (requestGatingRule_gatingRule_RuleConfigIsNull)
            {
                requestGatingRule_gatingRule_RuleConfig = null;
            }
            if (requestGatingRule_gatingRule_RuleConfig != null)
            {
                request.GatingRule.RuleConfig = requestGatingRule_gatingRule_RuleConfig;
                requestGatingRuleIsNull       = false;
            }
            // determine if request.GatingRule should be set to null
            if (requestGatingRuleIsNull)
            {
                request.GatingRule = null;
            }
            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);
        }