private Amazon.SageMaker.Model.CreateModelResponse CallAWSServiceOperation(IAmazonSageMaker client, Amazon.SageMaker.Model.CreateModelRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon SageMaker Service", "CreateModel"); try { #if DESKTOP return(client.CreateModel(request)); #elif CORECLR return(client.CreateModelAsync(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; } }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.SageMaker.Model.CreateModelRequest(); if (cmdletContext.Container != null) { request.Containers = cmdletContext.Container; } if (cmdletContext.EnableNetworkIsolation != null) { request.EnableNetworkIsolation = cmdletContext.EnableNetworkIsolation.Value; } if (cmdletContext.ExecutionRoleArn != null) { request.ExecutionRoleArn = cmdletContext.ExecutionRoleArn; } // populate InferenceExecutionConfig var requestInferenceExecutionConfigIsNull = true; request.InferenceExecutionConfig = new Amazon.SageMaker.Model.InferenceExecutionConfig(); Amazon.SageMaker.InferenceExecutionMode requestInferenceExecutionConfig_inferenceExecutionConfig_Mode = null; if (cmdletContext.InferenceExecutionConfig_Mode != null) { requestInferenceExecutionConfig_inferenceExecutionConfig_Mode = cmdletContext.InferenceExecutionConfig_Mode; } if (requestInferenceExecutionConfig_inferenceExecutionConfig_Mode != null) { request.InferenceExecutionConfig.Mode = requestInferenceExecutionConfig_inferenceExecutionConfig_Mode; requestInferenceExecutionConfigIsNull = false; } // determine if request.InferenceExecutionConfig should be set to null if (requestInferenceExecutionConfigIsNull) { request.InferenceExecutionConfig = null; } if (cmdletContext.ModelName != null) { request.ModelName = cmdletContext.ModelName; } if (cmdletContext.PrimaryContainer != null) { request.PrimaryContainer = cmdletContext.PrimaryContainer; } if (cmdletContext.Tag != null) { request.Tags = cmdletContext.Tag; } // populate VpcConfig var requestVpcConfigIsNull = true; request.VpcConfig = new Amazon.SageMaker.Model.VpcConfig(); List <System.String> requestVpcConfig_vpcConfig_SecurityGroupId = null; if (cmdletContext.VpcConfig_SecurityGroupId != null) { requestVpcConfig_vpcConfig_SecurityGroupId = cmdletContext.VpcConfig_SecurityGroupId; } if (requestVpcConfig_vpcConfig_SecurityGroupId != null) { request.VpcConfig.SecurityGroupIds = requestVpcConfig_vpcConfig_SecurityGroupId; requestVpcConfigIsNull = false; } List <System.String> requestVpcConfig_vpcConfig_Subnet = null; if (cmdletContext.VpcConfig_Subnet != null) { requestVpcConfig_vpcConfig_Subnet = cmdletContext.VpcConfig_Subnet; } if (requestVpcConfig_vpcConfig_Subnet != null) { request.VpcConfig.Subnets = requestVpcConfig_vpcConfig_Subnet; requestVpcConfigIsNull = false; } // determine if request.VpcConfig should be set to null if (requestVpcConfigIsNull) { request.VpcConfig = 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); }