예제 #1
0
 private Amazon.LookoutMetrics.Model.CreateAnomalyDetectorResponse CallAWSServiceOperation(IAmazonLookoutMetrics client, Amazon.LookoutMetrics.Model.CreateAnomalyDetectorRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Lookout for Metrics", "CreateAnomalyDetector");
     try
     {
         #if DESKTOP
         return(client.CreateAnomalyDetector(request));
         #elif CORECLR
         return(client.CreateAnomalyDetectorAsync(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.LookoutMetrics.Model.CreateAnomalyDetectorRequest();


            // populate AnomalyDetectorConfig
            var requestAnomalyDetectorConfigIsNull = true;

            request.AnomalyDetectorConfig = new Amazon.LookoutMetrics.Model.AnomalyDetectorConfig();
            Amazon.LookoutMetrics.Frequency requestAnomalyDetectorConfig_anomalyDetectorConfig_AnomalyDetectorFrequency = null;
            if (cmdletContext.AnomalyDetectorConfig_AnomalyDetectorFrequency != null)
            {
                requestAnomalyDetectorConfig_anomalyDetectorConfig_AnomalyDetectorFrequency = cmdletContext.AnomalyDetectorConfig_AnomalyDetectorFrequency;
            }
            if (requestAnomalyDetectorConfig_anomalyDetectorConfig_AnomalyDetectorFrequency != null)
            {
                request.AnomalyDetectorConfig.AnomalyDetectorFrequency = requestAnomalyDetectorConfig_anomalyDetectorConfig_AnomalyDetectorFrequency;
                requestAnomalyDetectorConfigIsNull = false;
            }
            // determine if request.AnomalyDetectorConfig should be set to null
            if (requestAnomalyDetectorConfigIsNull)
            {
                request.AnomalyDetectorConfig = null;
            }
            if (cmdletContext.AnomalyDetectorDescription != null)
            {
                request.AnomalyDetectorDescription = cmdletContext.AnomalyDetectorDescription;
            }
            if (cmdletContext.AnomalyDetectorName != null)
            {
                request.AnomalyDetectorName = cmdletContext.AnomalyDetectorName;
            }
            if (cmdletContext.KmsKeyArn != null)
            {
                request.KmsKeyArn = cmdletContext.KmsKeyArn;
            }
            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);
        }