예제 #1
0
 private Amazon.Braket.Model.CreateJobResponse CallAWSServiceOperation(IAmazonBraket client, Amazon.Braket.Model.CreateJobRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Braket", "CreateJob");
     try
     {
         #if DESKTOP
         return(client.CreateJob(request));
         #elif CORECLR
         return(client.CreateJobAsync(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.Braket.Model.CreateJobRequest();


            // populate AlgorithmSpecification
            var requestAlgorithmSpecificationIsNull = true;

            request.AlgorithmSpecification = new Amazon.Braket.Model.AlgorithmSpecification();
            Amazon.Braket.Model.ContainerImage requestAlgorithmSpecification_algorithmSpecification_ContainerImage = null;

            // populate ContainerImage
            var requestAlgorithmSpecification_algorithmSpecification_ContainerImageIsNull = true;

            requestAlgorithmSpecification_algorithmSpecification_ContainerImage = new Amazon.Braket.Model.ContainerImage();
            System.String requestAlgorithmSpecification_algorithmSpecification_ContainerImage_containerImage_Uri = null;
            if (cmdletContext.ContainerImage_Uri != null)
            {
                requestAlgorithmSpecification_algorithmSpecification_ContainerImage_containerImage_Uri = cmdletContext.ContainerImage_Uri;
            }
            if (requestAlgorithmSpecification_algorithmSpecification_ContainerImage_containerImage_Uri != null)
            {
                requestAlgorithmSpecification_algorithmSpecification_ContainerImage.Uri   = requestAlgorithmSpecification_algorithmSpecification_ContainerImage_containerImage_Uri;
                requestAlgorithmSpecification_algorithmSpecification_ContainerImageIsNull = false;
            }
            // determine if requestAlgorithmSpecification_algorithmSpecification_ContainerImage should be set to null
            if (requestAlgorithmSpecification_algorithmSpecification_ContainerImageIsNull)
            {
                requestAlgorithmSpecification_algorithmSpecification_ContainerImage = null;
            }
            if (requestAlgorithmSpecification_algorithmSpecification_ContainerImage != null)
            {
                request.AlgorithmSpecification.ContainerImage = requestAlgorithmSpecification_algorithmSpecification_ContainerImage;
                requestAlgorithmSpecificationIsNull           = false;
            }
            Amazon.Braket.Model.ScriptModeConfig requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig = null;

            // populate ScriptModeConfig
            var requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfigIsNull = true;

            requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig = new Amazon.Braket.Model.ScriptModeConfig();
            Amazon.Braket.CompressionType requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig_scriptModeConfig_CompressionType = null;
            if (cmdletContext.ScriptModeConfig_CompressionType != null)
            {
                requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig_scriptModeConfig_CompressionType = cmdletContext.ScriptModeConfig_CompressionType;
            }
            if (requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig_scriptModeConfig_CompressionType != null)
            {
                requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig.CompressionType = requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig_scriptModeConfig_CompressionType;
                requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfigIsNull           = false;
            }
            System.String requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig_scriptModeConfig_EntryPoint = null;
            if (cmdletContext.ScriptModeConfig_EntryPoint != null)
            {
                requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig_scriptModeConfig_EntryPoint = cmdletContext.ScriptModeConfig_EntryPoint;
            }
            if (requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig_scriptModeConfig_EntryPoint != null)
            {
                requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig.EntryPoint = requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig_scriptModeConfig_EntryPoint;
                requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfigIsNull      = false;
            }
            System.String requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig_scriptModeConfig_S3Uri = null;
            if (cmdletContext.ScriptModeConfig_S3Uri != null)
            {
                requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig_scriptModeConfig_S3Uri = cmdletContext.ScriptModeConfig_S3Uri;
            }
            if (requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig_scriptModeConfig_S3Uri != null)
            {
                requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig.S3Uri = requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig_scriptModeConfig_S3Uri;
                requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfigIsNull = false;
            }
            // determine if requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig should be set to null
            if (requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfigIsNull)
            {
                requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig = null;
            }
            if (requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig != null)
            {
                request.AlgorithmSpecification.ScriptModeConfig = requestAlgorithmSpecification_algorithmSpecification_ScriptModeConfig;
                requestAlgorithmSpecificationIsNull             = false;
            }
            // determine if request.AlgorithmSpecification should be set to null
            if (requestAlgorithmSpecificationIsNull)
            {
                request.AlgorithmSpecification = null;
            }

            // populate CheckpointConfig
            var requestCheckpointConfigIsNull = true;

            request.CheckpointConfig = new Amazon.Braket.Model.JobCheckpointConfig();
            System.String requestCheckpointConfig_checkpointConfig_LocalPath = null;
            if (cmdletContext.CheckpointConfig_LocalPath != null)
            {
                requestCheckpointConfig_checkpointConfig_LocalPath = cmdletContext.CheckpointConfig_LocalPath;
            }
            if (requestCheckpointConfig_checkpointConfig_LocalPath != null)
            {
                request.CheckpointConfig.LocalPath = requestCheckpointConfig_checkpointConfig_LocalPath;
                requestCheckpointConfigIsNull      = false;
            }
            System.String requestCheckpointConfig_checkpointConfig_S3Uri = null;
            if (cmdletContext.CheckpointConfig_S3Uri != null)
            {
                requestCheckpointConfig_checkpointConfig_S3Uri = cmdletContext.CheckpointConfig_S3Uri;
            }
            if (requestCheckpointConfig_checkpointConfig_S3Uri != null)
            {
                request.CheckpointConfig.S3Uri = requestCheckpointConfig_checkpointConfig_S3Uri;
                requestCheckpointConfigIsNull  = false;
            }
            // determine if request.CheckpointConfig should be set to null
            if (requestCheckpointConfigIsNull)
            {
                request.CheckpointConfig = null;
            }
            if (cmdletContext.ClientToken != null)
            {
                request.ClientToken = cmdletContext.ClientToken;
            }

            // populate DeviceConfig
            var requestDeviceConfigIsNull = true;

            request.DeviceConfig = new Amazon.Braket.Model.DeviceConfig();
            System.String requestDeviceConfig_deviceConfig_Device = null;
            if (cmdletContext.DeviceConfig_Device != null)
            {
                requestDeviceConfig_deviceConfig_Device = cmdletContext.DeviceConfig_Device;
            }
            if (requestDeviceConfig_deviceConfig_Device != null)
            {
                request.DeviceConfig.Device = requestDeviceConfig_deviceConfig_Device;
                requestDeviceConfigIsNull   = false;
            }
            // determine if request.DeviceConfig should be set to null
            if (requestDeviceConfigIsNull)
            {
                request.DeviceConfig = null;
            }
            if (cmdletContext.HyperParameter != null)
            {
                request.HyperParameters = cmdletContext.HyperParameter;
            }
            if (cmdletContext.InputDataConfig != null)
            {
                request.InputDataConfig = cmdletContext.InputDataConfig;
            }

            // populate InstanceConfig
            var requestInstanceConfigIsNull = true;

            request.InstanceConfig = new Amazon.Braket.Model.InstanceConfig();
            Amazon.Braket.InstanceType requestInstanceConfig_instanceConfig_InstanceType = null;
            if (cmdletContext.InstanceConfig_InstanceType != null)
            {
                requestInstanceConfig_instanceConfig_InstanceType = cmdletContext.InstanceConfig_InstanceType;
            }
            if (requestInstanceConfig_instanceConfig_InstanceType != null)
            {
                request.InstanceConfig.InstanceType = requestInstanceConfig_instanceConfig_InstanceType;
                requestInstanceConfigIsNull         = false;
            }
            System.Int32?requestInstanceConfig_instanceConfig_VolumeSizeInGb = null;
            if (cmdletContext.InstanceConfig_VolumeSizeInGb != null)
            {
                requestInstanceConfig_instanceConfig_VolumeSizeInGb = cmdletContext.InstanceConfig_VolumeSizeInGb.Value;
            }
            if (requestInstanceConfig_instanceConfig_VolumeSizeInGb != null)
            {
                request.InstanceConfig.VolumeSizeInGb = requestInstanceConfig_instanceConfig_VolumeSizeInGb.Value;
                requestInstanceConfigIsNull           = false;
            }
            // determine if request.InstanceConfig should be set to null
            if (requestInstanceConfigIsNull)
            {
                request.InstanceConfig = null;
            }
            if (cmdletContext.JobName != null)
            {
                request.JobName = cmdletContext.JobName;
            }

            // populate OutputDataConfig
            var requestOutputDataConfigIsNull = true;

            request.OutputDataConfig = new Amazon.Braket.Model.JobOutputDataConfig();
            System.String requestOutputDataConfig_outputDataConfig_KmsKeyId = null;
            if (cmdletContext.OutputDataConfig_KmsKeyId != null)
            {
                requestOutputDataConfig_outputDataConfig_KmsKeyId = cmdletContext.OutputDataConfig_KmsKeyId;
            }
            if (requestOutputDataConfig_outputDataConfig_KmsKeyId != null)
            {
                request.OutputDataConfig.KmsKeyId = requestOutputDataConfig_outputDataConfig_KmsKeyId;
                requestOutputDataConfigIsNull     = false;
            }
            System.String requestOutputDataConfig_outputDataConfig_S3Path = null;
            if (cmdletContext.OutputDataConfig_S3Path != null)
            {
                requestOutputDataConfig_outputDataConfig_S3Path = cmdletContext.OutputDataConfig_S3Path;
            }
            if (requestOutputDataConfig_outputDataConfig_S3Path != null)
            {
                request.OutputDataConfig.S3Path = requestOutputDataConfig_outputDataConfig_S3Path;
                requestOutputDataConfigIsNull   = false;
            }
            // determine if request.OutputDataConfig should be set to null
            if (requestOutputDataConfigIsNull)
            {
                request.OutputDataConfig = null;
            }
            if (cmdletContext.RoleArn != null)
            {
                request.RoleArn = cmdletContext.RoleArn;
            }

            // populate StoppingCondition
            var requestStoppingConditionIsNull = true;

            request.StoppingCondition = new Amazon.Braket.Model.JobStoppingCondition();
            System.Int32?requestStoppingCondition_stoppingCondition_MaxRuntimeInSecond = null;
            if (cmdletContext.StoppingCondition_MaxRuntimeInSecond != null)
            {
                requestStoppingCondition_stoppingCondition_MaxRuntimeInSecond = cmdletContext.StoppingCondition_MaxRuntimeInSecond.Value;
            }
            if (requestStoppingCondition_stoppingCondition_MaxRuntimeInSecond != null)
            {
                request.StoppingCondition.MaxRuntimeInSeconds = requestStoppingCondition_stoppingCondition_MaxRuntimeInSecond.Value;
                requestStoppingConditionIsNull = false;
            }
            // determine if request.StoppingCondition should be set to null
            if (requestStoppingConditionIsNull)
            {
                request.StoppingCondition = null;
            }
            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);
        }