コード例 #1
0
 private Amazon.ForecastService.Model.CreatePredictorResponse CallAWSServiceOperation(IAmazonForecastService client, Amazon.ForecastService.Model.CreatePredictorRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Forecast Service", "CreatePredictor");
     try
     {
         #if DESKTOP
         return(client.CreatePredictor(request));
         #elif CORECLR
         return(client.CreatePredictorAsync(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.ForecastService.Model.CreatePredictorRequest();

            if (cmdletContext.AlgorithmArn != null)
            {
                request.AlgorithmArn = cmdletContext.AlgorithmArn;
            }
            if (cmdletContext.AutoMLOverrideStrategy != null)
            {
                request.AutoMLOverrideStrategy = cmdletContext.AutoMLOverrideStrategy;
            }

            // populate EncryptionConfig
            var requestEncryptionConfigIsNull = true;

            request.EncryptionConfig = new Amazon.ForecastService.Model.EncryptionConfig();
            System.String requestEncryptionConfig_encryptionConfig_KMSKeyArn = null;
            if (cmdletContext.EncryptionConfig_KMSKeyArn != null)
            {
                requestEncryptionConfig_encryptionConfig_KMSKeyArn = cmdletContext.EncryptionConfig_KMSKeyArn;
            }
            if (requestEncryptionConfig_encryptionConfig_KMSKeyArn != null)
            {
                request.EncryptionConfig.KMSKeyArn = requestEncryptionConfig_encryptionConfig_KMSKeyArn;
                requestEncryptionConfigIsNull      = false;
            }
            System.String requestEncryptionConfig_encryptionConfig_RoleArn = null;
            if (cmdletContext.EncryptionConfig_RoleArn != null)
            {
                requestEncryptionConfig_encryptionConfig_RoleArn = cmdletContext.EncryptionConfig_RoleArn;
            }
            if (requestEncryptionConfig_encryptionConfig_RoleArn != null)
            {
                request.EncryptionConfig.RoleArn = requestEncryptionConfig_encryptionConfig_RoleArn;
                requestEncryptionConfigIsNull    = false;
            }
            // determine if request.EncryptionConfig should be set to null
            if (requestEncryptionConfigIsNull)
            {
                request.EncryptionConfig = null;
            }

            // populate EvaluationParameters
            var requestEvaluationParametersIsNull = true;

            request.EvaluationParameters = new Amazon.ForecastService.Model.EvaluationParameters();
            System.Int32?requestEvaluationParameters_evaluationParameters_BackTestWindowOffset = null;
            if (cmdletContext.EvaluationParameters_BackTestWindowOffset != null)
            {
                requestEvaluationParameters_evaluationParameters_BackTestWindowOffset = cmdletContext.EvaluationParameters_BackTestWindowOffset.Value;
            }
            if (requestEvaluationParameters_evaluationParameters_BackTestWindowOffset != null)
            {
                request.EvaluationParameters.BackTestWindowOffset = requestEvaluationParameters_evaluationParameters_BackTestWindowOffset.Value;
                requestEvaluationParametersIsNull = false;
            }
            System.Int32?requestEvaluationParameters_evaluationParameters_NumberOfBacktestWindow = null;
            if (cmdletContext.EvaluationParameters_NumberOfBacktestWindow != null)
            {
                requestEvaluationParameters_evaluationParameters_NumberOfBacktestWindow = cmdletContext.EvaluationParameters_NumberOfBacktestWindow.Value;
            }
            if (requestEvaluationParameters_evaluationParameters_NumberOfBacktestWindow != null)
            {
                request.EvaluationParameters.NumberOfBacktestWindows = requestEvaluationParameters_evaluationParameters_NumberOfBacktestWindow.Value;
                requestEvaluationParametersIsNull = false;
            }
            // determine if request.EvaluationParameters should be set to null
            if (requestEvaluationParametersIsNull)
            {
                request.EvaluationParameters = null;
            }

            // populate FeaturizationConfig
            var requestFeaturizationConfigIsNull = true;

            request.FeaturizationConfig = new Amazon.ForecastService.Model.FeaturizationConfig();
            List <Amazon.ForecastService.Model.Featurization> requestFeaturizationConfig_featurizationConfig_Featurization = null;

            if (cmdletContext.FeaturizationConfig_Featurization != null)
            {
                requestFeaturizationConfig_featurizationConfig_Featurization = cmdletContext.FeaturizationConfig_Featurization;
            }
            if (requestFeaturizationConfig_featurizationConfig_Featurization != null)
            {
                request.FeaturizationConfig.Featurizations = requestFeaturizationConfig_featurizationConfig_Featurization;
                requestFeaturizationConfigIsNull           = false;
            }
            List <System.String> requestFeaturizationConfig_featurizationConfig_ForecastDimension = null;

            if (cmdletContext.FeaturizationConfig_ForecastDimension != null)
            {
                requestFeaturizationConfig_featurizationConfig_ForecastDimension = cmdletContext.FeaturizationConfig_ForecastDimension;
            }
            if (requestFeaturizationConfig_featurizationConfig_ForecastDimension != null)
            {
                request.FeaturizationConfig.ForecastDimensions = requestFeaturizationConfig_featurizationConfig_ForecastDimension;
                requestFeaturizationConfigIsNull = false;
            }
            System.String requestFeaturizationConfig_featurizationConfig_ForecastFrequency = null;
            if (cmdletContext.FeaturizationConfig_ForecastFrequency != null)
            {
                requestFeaturizationConfig_featurizationConfig_ForecastFrequency = cmdletContext.FeaturizationConfig_ForecastFrequency;
            }
            if (requestFeaturizationConfig_featurizationConfig_ForecastFrequency != null)
            {
                request.FeaturizationConfig.ForecastFrequency = requestFeaturizationConfig_featurizationConfig_ForecastFrequency;
                requestFeaturizationConfigIsNull = false;
            }
            // determine if request.FeaturizationConfig should be set to null
            if (requestFeaturizationConfigIsNull)
            {
                request.FeaturizationConfig = null;
            }
            if (cmdletContext.ForecastHorizon != null)
            {
                request.ForecastHorizon = cmdletContext.ForecastHorizon.Value;
            }
            if (cmdletContext.ForecastType != null)
            {
                request.ForecastTypes = cmdletContext.ForecastType;
            }

            // populate HPOConfig
            var requestHPOConfigIsNull = true;

            request.HPOConfig = new Amazon.ForecastService.Model.HyperParameterTuningJobConfig();
            Amazon.ForecastService.Model.ParameterRanges requestHPOConfig_hPOConfig_ParameterRanges = null;

            // populate ParameterRanges
            var requestHPOConfig_hPOConfig_ParameterRangesIsNull = true;

            requestHPOConfig_hPOConfig_ParameterRanges = new Amazon.ForecastService.Model.ParameterRanges();
            List <Amazon.ForecastService.Model.CategoricalParameterRange> requestHPOConfig_hPOConfig_ParameterRanges_parameterRanges_CategoricalParameterRange = null;

            if (cmdletContext.ParameterRanges_CategoricalParameterRange != null)
            {
                requestHPOConfig_hPOConfig_ParameterRanges_parameterRanges_CategoricalParameterRange = cmdletContext.ParameterRanges_CategoricalParameterRange;
            }
            if (requestHPOConfig_hPOConfig_ParameterRanges_parameterRanges_CategoricalParameterRange != null)
            {
                requestHPOConfig_hPOConfig_ParameterRanges.CategoricalParameterRanges = requestHPOConfig_hPOConfig_ParameterRanges_parameterRanges_CategoricalParameterRange;
                requestHPOConfig_hPOConfig_ParameterRangesIsNull = false;
            }
            List <Amazon.ForecastService.Model.ContinuousParameterRange> requestHPOConfig_hPOConfig_ParameterRanges_parameterRanges_ContinuousParameterRange = null;

            if (cmdletContext.ParameterRanges_ContinuousParameterRange != null)
            {
                requestHPOConfig_hPOConfig_ParameterRanges_parameterRanges_ContinuousParameterRange = cmdletContext.ParameterRanges_ContinuousParameterRange;
            }
            if (requestHPOConfig_hPOConfig_ParameterRanges_parameterRanges_ContinuousParameterRange != null)
            {
                requestHPOConfig_hPOConfig_ParameterRanges.ContinuousParameterRanges = requestHPOConfig_hPOConfig_ParameterRanges_parameterRanges_ContinuousParameterRange;
                requestHPOConfig_hPOConfig_ParameterRangesIsNull = false;
            }
            List <Amazon.ForecastService.Model.IntegerParameterRange> requestHPOConfig_hPOConfig_ParameterRanges_parameterRanges_IntegerParameterRange = null;

            if (cmdletContext.ParameterRanges_IntegerParameterRange != null)
            {
                requestHPOConfig_hPOConfig_ParameterRanges_parameterRanges_IntegerParameterRange = cmdletContext.ParameterRanges_IntegerParameterRange;
            }
            if (requestHPOConfig_hPOConfig_ParameterRanges_parameterRanges_IntegerParameterRange != null)
            {
                requestHPOConfig_hPOConfig_ParameterRanges.IntegerParameterRanges = requestHPOConfig_hPOConfig_ParameterRanges_parameterRanges_IntegerParameterRange;
                requestHPOConfig_hPOConfig_ParameterRangesIsNull = false;
            }
            // determine if requestHPOConfig_hPOConfig_ParameterRanges should be set to null
            if (requestHPOConfig_hPOConfig_ParameterRangesIsNull)
            {
                requestHPOConfig_hPOConfig_ParameterRanges = null;
            }
            if (requestHPOConfig_hPOConfig_ParameterRanges != null)
            {
                request.HPOConfig.ParameterRanges = requestHPOConfig_hPOConfig_ParameterRanges;
                requestHPOConfigIsNull            = false;
            }
            // determine if request.HPOConfig should be set to null
            if (requestHPOConfigIsNull)
            {
                request.HPOConfig = null;
            }

            // populate InputDataConfig
            var requestInputDataConfigIsNull = true;

            request.InputDataConfig = new Amazon.ForecastService.Model.InputDataConfig();
            System.String requestInputDataConfig_inputDataConfig_DatasetGroupArn = null;
            if (cmdletContext.InputDataConfig_DatasetGroupArn != null)
            {
                requestInputDataConfig_inputDataConfig_DatasetGroupArn = cmdletContext.InputDataConfig_DatasetGroupArn;
            }
            if (requestInputDataConfig_inputDataConfig_DatasetGroupArn != null)
            {
                request.InputDataConfig.DatasetGroupArn = requestInputDataConfig_inputDataConfig_DatasetGroupArn;
                requestInputDataConfigIsNull            = false;
            }
            List <Amazon.ForecastService.Model.SupplementaryFeature> requestInputDataConfig_inputDataConfig_SupplementaryFeature = null;

            if (cmdletContext.InputDataConfig_SupplementaryFeature != null)
            {
                requestInputDataConfig_inputDataConfig_SupplementaryFeature = cmdletContext.InputDataConfig_SupplementaryFeature;
            }
            if (requestInputDataConfig_inputDataConfig_SupplementaryFeature != null)
            {
                request.InputDataConfig.SupplementaryFeatures = requestInputDataConfig_inputDataConfig_SupplementaryFeature;
                requestInputDataConfigIsNull = false;
            }
            // determine if request.InputDataConfig should be set to null
            if (requestInputDataConfigIsNull)
            {
                request.InputDataConfig = null;
            }
            if (cmdletContext.OptimizationMetric != null)
            {
                request.OptimizationMetric = cmdletContext.OptimizationMetric;
            }
            if (cmdletContext.PerformAutoML != null)
            {
                request.PerformAutoML = cmdletContext.PerformAutoML.Value;
            }
            if (cmdletContext.PerformHPO != null)
            {
                request.PerformHPO = cmdletContext.PerformHPO.Value;
            }
            if (cmdletContext.PredictorName != null)
            {
                request.PredictorName = cmdletContext.PredictorName;
            }
            if (cmdletContext.Tag != null)
            {
                request.Tags = cmdletContext.Tag;
            }
            if (cmdletContext.TrainingParameter != null)
            {
                request.TrainingParameters = cmdletContext.TrainingParameter;
            }

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