예제 #1
0
 private Amazon.CloudWatchEvidently.Model.CreateExperimentResponse CallAWSServiceOperation(IAmazonCloudWatchEvidently client, Amazon.CloudWatchEvidently.Model.CreateExperimentRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon CloudWatch Evidently", "CreateExperiment");
     try
     {
         #if DESKTOP
         return(client.CreateExperiment(request));
         #elif CORECLR
         return(client.CreateExperimentAsync(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.CloudWatchEvidently.Model.CreateExperimentRequest();

            if (cmdletContext.Description != null)
            {
                request.Description = cmdletContext.Description;
            }
            if (cmdletContext.MetricGoal != null)
            {
                request.MetricGoals = cmdletContext.MetricGoal;
            }
            if (cmdletContext.Name != null)
            {
                request.Name = cmdletContext.Name;
            }

            // populate OnlineAbConfig
            var requestOnlineAbConfigIsNull = true;

            request.OnlineAbConfig = new Amazon.CloudWatchEvidently.Model.OnlineAbConfig();
            System.String requestOnlineAbConfig_onlineAbConfig_ControlTreatmentName = null;
            if (cmdletContext.OnlineAbConfig_ControlTreatmentName != null)
            {
                requestOnlineAbConfig_onlineAbConfig_ControlTreatmentName = cmdletContext.OnlineAbConfig_ControlTreatmentName;
            }
            if (requestOnlineAbConfig_onlineAbConfig_ControlTreatmentName != null)
            {
                request.OnlineAbConfig.ControlTreatmentName = requestOnlineAbConfig_onlineAbConfig_ControlTreatmentName;
                requestOnlineAbConfigIsNull = false;
            }
            Dictionary <System.String, System.Int64> requestOnlineAbConfig_onlineAbConfig_TreatmentWeight = null;

            if (cmdletContext.OnlineAbConfig_TreatmentWeight != null)
            {
                requestOnlineAbConfig_onlineAbConfig_TreatmentWeight = cmdletContext.OnlineAbConfig_TreatmentWeight;
            }
            if (requestOnlineAbConfig_onlineAbConfig_TreatmentWeight != null)
            {
                request.OnlineAbConfig.TreatmentWeights = requestOnlineAbConfig_onlineAbConfig_TreatmentWeight;
                requestOnlineAbConfigIsNull             = false;
            }
            // determine if request.OnlineAbConfig should be set to null
            if (requestOnlineAbConfigIsNull)
            {
                request.OnlineAbConfig = null;
            }
            if (cmdletContext.Project != null)
            {
                request.Project = cmdletContext.Project;
            }
            if (cmdletContext.RandomizationSalt != null)
            {
                request.RandomizationSalt = cmdletContext.RandomizationSalt;
            }
            if (cmdletContext.SamplingRate != null)
            {
                request.SamplingRate = cmdletContext.SamplingRate.Value;
            }
            if (cmdletContext.Tag != null)
            {
                request.Tags = cmdletContext.Tag;
            }
            if (cmdletContext.Treatment != null)
            {
                request.Treatments = cmdletContext.Treatment;
            }

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