private Amazon.SageMakerRuntime.Model.InvokeEndpointResponse CallAWSServiceOperation(IAmazonSageMakerRuntime client, Amazon.SageMakerRuntime.Model.InvokeEndpointRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon SageMaker Runtime", "InvokeEndpoint"); try { #if DESKTOP return(client.InvokeEndpoint(request)); #elif CORECLR return(client.InvokeEndpointAsync(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) { System.IO.MemoryStream _BodyStream = null; try { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.SageMakerRuntime.Model.InvokeEndpointRequest(); if (cmdletContext.Accept != null) { request.Accept = cmdletContext.Accept; } if (cmdletContext.Body != null) { _BodyStream = new System.IO.MemoryStream(cmdletContext.Body); request.Body = _BodyStream; } if (cmdletContext.ContentType != null) { request.ContentType = cmdletContext.ContentType; } if (cmdletContext.CustomAttribute != null) { request.CustomAttributes = cmdletContext.CustomAttribute; } if (cmdletContext.EndpointName != null) { request.EndpointName = cmdletContext.EndpointName; } if (cmdletContext.TargetModel != null) { request.TargetModel = cmdletContext.TargetModel; } 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); } finally { if (_BodyStream != null) { _BodyStream.Dispose(); } } }