コード例 #1
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.CloudWatch.Model.DeleteAnomalyDetectorRequest();

            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);
        }
コード例 #2
0
 private Amazon.CloudWatch.Model.DeleteAnomalyDetectorResponse CallAWSServiceOperation(IAmazonCloudWatch client, Amazon.CloudWatch.Model.DeleteAnomalyDetectorRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon CloudWatch", "DeleteAnomalyDetector");
     try
     {
         #if DESKTOP
         return(client.DeleteAnomalyDetector(request));
         #elif CORECLR
         return(client.DeleteAnomalyDetectorAsync(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;
     }
 }
コード例 #3
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.CloudWatch.Model.DeleteAnomalyDetectorRequest();

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