Example #1
0
 private Amazon.SageMaker.Model.CreateContextResponse CallAWSServiceOperation(IAmazonSageMaker client, Amazon.SageMaker.Model.CreateContextRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon SageMaker Service", "CreateContext");
     try
     {
         #if DESKTOP
         return(client.CreateContext(request));
         #elif CORECLR
         return(client.CreateContextAsync(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.CreateContextRequest();

            if (cmdletContext.ContextName != null)
            {
                request.ContextName = cmdletContext.ContextName;
            }
            if (cmdletContext.ContextType != null)
            {
                request.ContextType = cmdletContext.ContextType;
            }
            if (cmdletContext.Description != null)
            {
                request.Description = cmdletContext.Description;
            }
            if (cmdletContext.Property != null)
            {
                request.Properties = cmdletContext.Property;
            }

            // populate Source
            var requestSourceIsNull = true;

            request.Source = new Amazon.SageMaker.Model.ContextSource();
            System.String requestSource_source_SourceId = null;
            if (cmdletContext.Source_SourceId != null)
            {
                requestSource_source_SourceId = cmdletContext.Source_SourceId;
            }
            if (requestSource_source_SourceId != null)
            {
                request.Source.SourceId = requestSource_source_SourceId;
                requestSourceIsNull     = false;
            }
            System.String requestSource_source_SourceType = null;
            if (cmdletContext.Source_SourceType != null)
            {
                requestSource_source_SourceType = cmdletContext.Source_SourceType;
            }
            if (requestSource_source_SourceType != null)
            {
                request.Source.SourceType = requestSource_source_SourceType;
                requestSourceIsNull       = false;
            }
            System.String requestSource_source_SourceUri = null;
            if (cmdletContext.Source_SourceUri != null)
            {
                requestSource_source_SourceUri = cmdletContext.Source_SourceUri;
            }
            if (requestSource_source_SourceUri != null)
            {
                request.Source.SourceUri = requestSource_source_SourceUri;
                requestSourceIsNull      = false;
            }
            // determine if request.Source should be set to null
            if (requestSourceIsNull)
            {
                request.Source = 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);
        }