Example #1
0
 private Amazon.SageMaker.Model.CreateAlgorithmResponse CallAWSServiceOperation(IAmazonSageMaker client, Amazon.SageMaker.Model.CreateAlgorithmRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon SageMaker Service", "CreateAlgorithm");
     try
     {
         #if DESKTOP
         return(client.CreateAlgorithm(request));
         #elif CORECLR
         return(client.CreateAlgorithmAsync(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;
     }
 }
Example #2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.SageMaker.Model.CreateAlgorithmRequest();

            if (cmdletContext.AlgorithmDescription != null)
            {
                request.AlgorithmDescription = cmdletContext.AlgorithmDescription;
            }
            if (cmdletContext.AlgorithmName != null)
            {
                request.AlgorithmName = cmdletContext.AlgorithmName;
            }
            if (cmdletContext.CertifyForMarketplace != null)
            {
                request.CertifyForMarketplace = cmdletContext.CertifyForMarketplace.Value;
            }

            // populate InferenceSpecification
            var requestInferenceSpecificationIsNull = true;

            request.InferenceSpecification = new Amazon.SageMaker.Model.InferenceSpecification();
            List <Amazon.SageMaker.Model.ModelPackageContainerDefinition> requestInferenceSpecification_inferenceSpecification_Container = null;

            if (cmdletContext.InferenceSpecification_Container != null)
            {
                requestInferenceSpecification_inferenceSpecification_Container = cmdletContext.InferenceSpecification_Container;
            }
            if (requestInferenceSpecification_inferenceSpecification_Container != null)
            {
                request.InferenceSpecification.Containers = requestInferenceSpecification_inferenceSpecification_Container;
                requestInferenceSpecificationIsNull       = false;
            }
            List <System.String> requestInferenceSpecification_inferenceSpecification_SupportedContentType = null;

            if (cmdletContext.InferenceSpecification_SupportedContentType != null)
            {
                requestInferenceSpecification_inferenceSpecification_SupportedContentType = cmdletContext.InferenceSpecification_SupportedContentType;
            }
            if (requestInferenceSpecification_inferenceSpecification_SupportedContentType != null)
            {
                request.InferenceSpecification.SupportedContentTypes = requestInferenceSpecification_inferenceSpecification_SupportedContentType;
                requestInferenceSpecificationIsNull = false;
            }
            List <System.String> requestInferenceSpecification_inferenceSpecification_SupportedRealtimeInferenceInstanceType = null;

            if (cmdletContext.InferenceSpecification_SupportedRealtimeInferenceInstanceType != null)
            {
                requestInferenceSpecification_inferenceSpecification_SupportedRealtimeInferenceInstanceType = cmdletContext.InferenceSpecification_SupportedRealtimeInferenceInstanceType;
            }
            if (requestInferenceSpecification_inferenceSpecification_SupportedRealtimeInferenceInstanceType != null)
            {
                request.InferenceSpecification.SupportedRealtimeInferenceInstanceTypes = requestInferenceSpecification_inferenceSpecification_SupportedRealtimeInferenceInstanceType;
                requestInferenceSpecificationIsNull = false;
            }
            List <System.String> requestInferenceSpecification_inferenceSpecification_SupportedResponseMIMEType = null;

            if (cmdletContext.InferenceSpecification_SupportedResponseMIMEType != null)
            {
                requestInferenceSpecification_inferenceSpecification_SupportedResponseMIMEType = cmdletContext.InferenceSpecification_SupportedResponseMIMEType;
            }
            if (requestInferenceSpecification_inferenceSpecification_SupportedResponseMIMEType != null)
            {
                request.InferenceSpecification.SupportedResponseMIMETypes = requestInferenceSpecification_inferenceSpecification_SupportedResponseMIMEType;
                requestInferenceSpecificationIsNull = false;
            }
            List <System.String> requestInferenceSpecification_inferenceSpecification_SupportedTransformInstanceType = null;

            if (cmdletContext.InferenceSpecification_SupportedTransformInstanceType != null)
            {
                requestInferenceSpecification_inferenceSpecification_SupportedTransformInstanceType = cmdletContext.InferenceSpecification_SupportedTransformInstanceType;
            }
            if (requestInferenceSpecification_inferenceSpecification_SupportedTransformInstanceType != null)
            {
                request.InferenceSpecification.SupportedTransformInstanceTypes = requestInferenceSpecification_inferenceSpecification_SupportedTransformInstanceType;
                requestInferenceSpecificationIsNull = false;
            }
            // determine if request.InferenceSpecification should be set to null
            if (requestInferenceSpecificationIsNull)
            {
                request.InferenceSpecification = null;
            }

            // populate TrainingSpecification
            var requestTrainingSpecificationIsNull = true;

            request.TrainingSpecification = new Amazon.SageMaker.Model.TrainingSpecification();
            List <Amazon.SageMaker.Model.MetricDefinition> requestTrainingSpecification_trainingSpecification_MetricDefinition = null;

            if (cmdletContext.TrainingSpecification_MetricDefinition != null)
            {
                requestTrainingSpecification_trainingSpecification_MetricDefinition = cmdletContext.TrainingSpecification_MetricDefinition;
            }
            if (requestTrainingSpecification_trainingSpecification_MetricDefinition != null)
            {
                request.TrainingSpecification.MetricDefinitions = requestTrainingSpecification_trainingSpecification_MetricDefinition;
                requestTrainingSpecificationIsNull = false;
            }
            List <Amazon.SageMaker.Model.HyperParameterSpecification> requestTrainingSpecification_trainingSpecification_SupportedHyperParameter = null;

            if (cmdletContext.TrainingSpecification_SupportedHyperParameter != null)
            {
                requestTrainingSpecification_trainingSpecification_SupportedHyperParameter = cmdletContext.TrainingSpecification_SupportedHyperParameter;
            }
            if (requestTrainingSpecification_trainingSpecification_SupportedHyperParameter != null)
            {
                request.TrainingSpecification.SupportedHyperParameters = requestTrainingSpecification_trainingSpecification_SupportedHyperParameter;
                requestTrainingSpecificationIsNull = false;
            }
            List <System.String> requestTrainingSpecification_trainingSpecification_SupportedTrainingInstanceType = null;

            if (cmdletContext.TrainingSpecification_SupportedTrainingInstanceType != null)
            {
                requestTrainingSpecification_trainingSpecification_SupportedTrainingInstanceType = cmdletContext.TrainingSpecification_SupportedTrainingInstanceType;
            }
            if (requestTrainingSpecification_trainingSpecification_SupportedTrainingInstanceType != null)
            {
                request.TrainingSpecification.SupportedTrainingInstanceTypes = requestTrainingSpecification_trainingSpecification_SupportedTrainingInstanceType;
                requestTrainingSpecificationIsNull = false;
            }
            List <Amazon.SageMaker.Model.HyperParameterTuningJobObjective> requestTrainingSpecification_trainingSpecification_SupportedTuningJobObjectiveMetric = null;

            if (cmdletContext.TrainingSpecification_SupportedTuningJobObjectiveMetric != null)
            {
                requestTrainingSpecification_trainingSpecification_SupportedTuningJobObjectiveMetric = cmdletContext.TrainingSpecification_SupportedTuningJobObjectiveMetric;
            }
            if (requestTrainingSpecification_trainingSpecification_SupportedTuningJobObjectiveMetric != null)
            {
                request.TrainingSpecification.SupportedTuningJobObjectiveMetrics = requestTrainingSpecification_trainingSpecification_SupportedTuningJobObjectiveMetric;
                requestTrainingSpecificationIsNull = false;
            }
            System.Boolean?requestTrainingSpecification_trainingSpecification_SupportsDistributedTraining = null;
            if (cmdletContext.TrainingSpecification_SupportsDistributedTraining != null)
            {
                requestTrainingSpecification_trainingSpecification_SupportsDistributedTraining = cmdletContext.TrainingSpecification_SupportsDistributedTraining.Value;
            }
            if (requestTrainingSpecification_trainingSpecification_SupportsDistributedTraining != null)
            {
                request.TrainingSpecification.SupportsDistributedTraining = requestTrainingSpecification_trainingSpecification_SupportsDistributedTraining.Value;
                requestTrainingSpecificationIsNull = false;
            }
            List <Amazon.SageMaker.Model.ChannelSpecification> requestTrainingSpecification_trainingSpecification_TrainingChannel = null;

            if (cmdletContext.TrainingSpecification_TrainingChannel != null)
            {
                requestTrainingSpecification_trainingSpecification_TrainingChannel = cmdletContext.TrainingSpecification_TrainingChannel;
            }
            if (requestTrainingSpecification_trainingSpecification_TrainingChannel != null)
            {
                request.TrainingSpecification.TrainingChannels = requestTrainingSpecification_trainingSpecification_TrainingChannel;
                requestTrainingSpecificationIsNull             = false;
            }
            System.String requestTrainingSpecification_trainingSpecification_TrainingImage = null;
            if (cmdletContext.TrainingSpecification_TrainingImage != null)
            {
                requestTrainingSpecification_trainingSpecification_TrainingImage = cmdletContext.TrainingSpecification_TrainingImage;
            }
            if (requestTrainingSpecification_trainingSpecification_TrainingImage != null)
            {
                request.TrainingSpecification.TrainingImage = requestTrainingSpecification_trainingSpecification_TrainingImage;
                requestTrainingSpecificationIsNull          = false;
            }
            System.String requestTrainingSpecification_trainingSpecification_TrainingImageDigest = null;
            if (cmdletContext.TrainingSpecification_TrainingImageDigest != null)
            {
                requestTrainingSpecification_trainingSpecification_TrainingImageDigest = cmdletContext.TrainingSpecification_TrainingImageDigest;
            }
            if (requestTrainingSpecification_trainingSpecification_TrainingImageDigest != null)
            {
                request.TrainingSpecification.TrainingImageDigest = requestTrainingSpecification_trainingSpecification_TrainingImageDigest;
                requestTrainingSpecificationIsNull = false;
            }
            // determine if request.TrainingSpecification should be set to null
            if (requestTrainingSpecificationIsNull)
            {
                request.TrainingSpecification = null;
            }

            // populate ValidationSpecification
            var requestValidationSpecificationIsNull = true;

            request.ValidationSpecification = new Amazon.SageMaker.Model.AlgorithmValidationSpecification();
            List <Amazon.SageMaker.Model.AlgorithmValidationProfile> requestValidationSpecification_validationSpecification_ValidationProfile = null;

            if (cmdletContext.ValidationSpecification_ValidationProfile != null)
            {
                requestValidationSpecification_validationSpecification_ValidationProfile = cmdletContext.ValidationSpecification_ValidationProfile;
            }
            if (requestValidationSpecification_validationSpecification_ValidationProfile != null)
            {
                request.ValidationSpecification.ValidationProfiles = requestValidationSpecification_validationSpecification_ValidationProfile;
                requestValidationSpecificationIsNull = false;
            }
            System.String requestValidationSpecification_validationSpecification_ValidationRole = null;
            if (cmdletContext.ValidationSpecification_ValidationRole != null)
            {
                requestValidationSpecification_validationSpecification_ValidationRole = cmdletContext.ValidationSpecification_ValidationRole;
            }
            if (requestValidationSpecification_validationSpecification_ValidationRole != null)
            {
                request.ValidationSpecification.ValidationRole = requestValidationSpecification_validationSpecification_ValidationRole;
                requestValidationSpecificationIsNull           = false;
            }
            // determine if request.ValidationSpecification should be set to null
            if (requestValidationSpecificationIsNull)
            {
                request.ValidationSpecification = null;
            }

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