public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.CloudWatch.Model.PutAnomalyDetectorRequest();


            // populate Configuration
            var requestConfigurationIsNull = true;

            request.Configuration = new Amazon.CloudWatch.Model.AnomalyDetectorConfiguration();
            List <Amazon.CloudWatch.Model.Range> requestConfiguration_configuration_ExcludedTimeRange = null;

            if (cmdletContext.Configuration_ExcludedTimeRange != null)
            {
                requestConfiguration_configuration_ExcludedTimeRange = cmdletContext.Configuration_ExcludedTimeRange;
            }
            if (requestConfiguration_configuration_ExcludedTimeRange != null)
            {
                request.Configuration.ExcludedTimeRanges = requestConfiguration_configuration_ExcludedTimeRange;
                requestConfigurationIsNull = false;
            }
            System.String requestConfiguration_configuration_MetricTimezone = null;
            if (cmdletContext.Configuration_MetricTimezone != null)
            {
                requestConfiguration_configuration_MetricTimezone = cmdletContext.Configuration_MetricTimezone;
            }
            if (requestConfiguration_configuration_MetricTimezone != null)
            {
                request.Configuration.MetricTimezone = requestConfiguration_configuration_MetricTimezone;
                requestConfigurationIsNull           = false;
            }
            // determine if request.Configuration should be set to null
            if (requestConfigurationIsNull)
            {
                request.Configuration = null;
            }
            #pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute
            if (cmdletContext.Dimension != null)
            {
                request.Dimensions = cmdletContext.Dimension;
            }
            #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute

            // populate MetricMathAnomalyDetector
            var requestMetricMathAnomalyDetectorIsNull = true;
            request.MetricMathAnomalyDetector = new Amazon.CloudWatch.Model.MetricMathAnomalyDetector();
            List <Amazon.CloudWatch.Model.MetricDataQuery> requestMetricMathAnomalyDetector_metricMathAnomalyDetector_MetricDataQuery = null;
            if (cmdletContext.MetricMathAnomalyDetector_MetricDataQuery != null)
            {
                requestMetricMathAnomalyDetector_metricMathAnomalyDetector_MetricDataQuery = cmdletContext.MetricMathAnomalyDetector_MetricDataQuery;
            }
            if (requestMetricMathAnomalyDetector_metricMathAnomalyDetector_MetricDataQuery != null)
            {
                request.MetricMathAnomalyDetector.MetricDataQueries = requestMetricMathAnomalyDetector_metricMathAnomalyDetector_MetricDataQuery;
                requestMetricMathAnomalyDetectorIsNull = false;
            }
            // determine if request.MetricMathAnomalyDetector should be set to null
            if (requestMetricMathAnomalyDetectorIsNull)
            {
                request.MetricMathAnomalyDetector = null;
            }
            #pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute
            if (cmdletContext.MetricName != null)
            {
                request.MetricName = cmdletContext.MetricName;
            }
            #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute
            #pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute
            if (cmdletContext.Namespace != null)
            {
                request.Namespace = cmdletContext.Namespace;
            }
            #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute

            // populate SingleMetricAnomalyDetector
            var requestSingleMetricAnomalyDetectorIsNull = true;
            request.SingleMetricAnomalyDetector = new Amazon.CloudWatch.Model.SingleMetricAnomalyDetector();
            List <Amazon.CloudWatch.Model.Dimension> requestSingleMetricAnomalyDetector_singleMetricAnomalyDetector_Dimension = null;
            if (cmdletContext.SingleMetricAnomalyDetector_Dimension != null)
            {
                requestSingleMetricAnomalyDetector_singleMetricAnomalyDetector_Dimension = cmdletContext.SingleMetricAnomalyDetector_Dimension;
            }
            if (requestSingleMetricAnomalyDetector_singleMetricAnomalyDetector_Dimension != null)
            {
                request.SingleMetricAnomalyDetector.Dimensions = requestSingleMetricAnomalyDetector_singleMetricAnomalyDetector_Dimension;
                requestSingleMetricAnomalyDetectorIsNull       = false;
            }
            System.String requestSingleMetricAnomalyDetector_singleMetricAnomalyDetector_MetricName = null;
            if (cmdletContext.SingleMetricAnomalyDetector_MetricName != null)
            {
                requestSingleMetricAnomalyDetector_singleMetricAnomalyDetector_MetricName = cmdletContext.SingleMetricAnomalyDetector_MetricName;
            }
            if (requestSingleMetricAnomalyDetector_singleMetricAnomalyDetector_MetricName != null)
            {
                request.SingleMetricAnomalyDetector.MetricName = requestSingleMetricAnomalyDetector_singleMetricAnomalyDetector_MetricName;
                requestSingleMetricAnomalyDetectorIsNull       = false;
            }
            System.String requestSingleMetricAnomalyDetector_singleMetricAnomalyDetector_Namespace = null;
            if (cmdletContext.SingleMetricAnomalyDetector_Namespace != null)
            {
                requestSingleMetricAnomalyDetector_singleMetricAnomalyDetector_Namespace = cmdletContext.SingleMetricAnomalyDetector_Namespace;
            }
            if (requestSingleMetricAnomalyDetector_singleMetricAnomalyDetector_Namespace != null)
            {
                request.SingleMetricAnomalyDetector.Namespace = requestSingleMetricAnomalyDetector_singleMetricAnomalyDetector_Namespace;
                requestSingleMetricAnomalyDetectorIsNull      = false;
            }
            System.String requestSingleMetricAnomalyDetector_singleMetricAnomalyDetector_Stat = null;
            if (cmdletContext.SingleMetricAnomalyDetector_Stat != null)
            {
                requestSingleMetricAnomalyDetector_singleMetricAnomalyDetector_Stat = cmdletContext.SingleMetricAnomalyDetector_Stat;
            }
            if (requestSingleMetricAnomalyDetector_singleMetricAnomalyDetector_Stat != null)
            {
                request.SingleMetricAnomalyDetector.Stat = requestSingleMetricAnomalyDetector_singleMetricAnomalyDetector_Stat;
                requestSingleMetricAnomalyDetectorIsNull = false;
            }
            // determine if request.SingleMetricAnomalyDetector should be set to null
            if (requestSingleMetricAnomalyDetectorIsNull)
            {
                request.SingleMetricAnomalyDetector = null;
            }
            #pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute
            if (cmdletContext.Stat != null)
            {
                request.Stat = cmdletContext.Stat;
            }
            #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute

            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);
        }
 private Amazon.CloudWatch.Model.PutAnomalyDetectorResponse CallAWSServiceOperation(IAmazonCloudWatch client, Amazon.CloudWatch.Model.PutAnomalyDetectorRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon CloudWatch", "PutAnomalyDetector");
     try
     {
         #if DESKTOP
         return(client.PutAnomalyDetector(request));
         #elif CORECLR
         return(client.PutAnomalyDetectorAsync(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;
     }
 }
Exemple #3
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.CloudWatch.Model.PutAnomalyDetectorRequest();


            // populate Configuration
            var requestConfigurationIsNull = true;

            request.Configuration = new Amazon.CloudWatch.Model.AnomalyDetectorConfiguration();
            List <Amazon.CloudWatch.Model.Range> requestConfiguration_configuration_ExcludedTimeRange = null;

            if (cmdletContext.Configuration_ExcludedTimeRange != null)
            {
                requestConfiguration_configuration_ExcludedTimeRange = cmdletContext.Configuration_ExcludedTimeRange;
            }
            if (requestConfiguration_configuration_ExcludedTimeRange != null)
            {
                request.Configuration.ExcludedTimeRanges = requestConfiguration_configuration_ExcludedTimeRange;
                requestConfigurationIsNull = false;
            }
            System.String requestConfiguration_configuration_MetricTimezone = null;
            if (cmdletContext.Configuration_MetricTimezone != null)
            {
                requestConfiguration_configuration_MetricTimezone = cmdletContext.Configuration_MetricTimezone;
            }
            if (requestConfiguration_configuration_MetricTimezone != null)
            {
                request.Configuration.MetricTimezone = requestConfiguration_configuration_MetricTimezone;
                requestConfigurationIsNull           = false;
            }
            // determine if request.Configuration should be set to null
            if (requestConfigurationIsNull)
            {
                request.Configuration = null;
            }
            if (cmdletContext.Dimension != null)
            {
                request.Dimensions = cmdletContext.Dimension;
            }
            if (cmdletContext.MetricName != null)
            {
                request.MetricName = cmdletContext.MetricName;
            }
            if (cmdletContext.Namespace != null)
            {
                request.Namespace = cmdletContext.Namespace;
            }
            if (cmdletContext.Stat != null)
            {
                request.Stat = cmdletContext.Stat;
            }

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