private Amazon.Textract.Model.AnalyzeDocumentResponse CallAWSServiceOperation(IAmazonTextract client, Amazon.Textract.Model.AnalyzeDocumentRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Textract", "AnalyzeDocument"); try { #if DESKTOP return(client.AnalyzeDocument(request)); #elif CORECLR return(client.AnalyzeDocumentAsync(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 _Document_ByteStream = null; try { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.Textract.Model.AnalyzeDocumentRequest(); // populate Document var requestDocumentIsNull = true; request.Document = new Amazon.Textract.Model.Document(); System.IO.MemoryStream requestDocument_document_Byte = null; if (cmdletContext.Document_Byte != null) { _Document_ByteStream = new System.IO.MemoryStream(cmdletContext.Document_Byte); requestDocument_document_Byte = _Document_ByteStream; } if (requestDocument_document_Byte != null) { request.Document.Bytes = requestDocument_document_Byte; requestDocumentIsNull = false; } Amazon.Textract.Model.S3Object requestDocument_document_S3Object = null; // populate S3Object var requestDocument_document_S3ObjectIsNull = true; requestDocument_document_S3Object = new Amazon.Textract.Model.S3Object(); System.String requestDocument_document_S3Object_s3Object_Bucket = null; if (cmdletContext.S3Object_Bucket != null) { requestDocument_document_S3Object_s3Object_Bucket = cmdletContext.S3Object_Bucket; } if (requestDocument_document_S3Object_s3Object_Bucket != null) { requestDocument_document_S3Object.Bucket = requestDocument_document_S3Object_s3Object_Bucket; requestDocument_document_S3ObjectIsNull = false; } System.String requestDocument_document_S3Object_s3Object_Name = null; if (cmdletContext.S3Object_Name != null) { requestDocument_document_S3Object_s3Object_Name = cmdletContext.S3Object_Name; } if (requestDocument_document_S3Object_s3Object_Name != null) { requestDocument_document_S3Object.Name = requestDocument_document_S3Object_s3Object_Name; requestDocument_document_S3ObjectIsNull = false; } System.String requestDocument_document_S3Object_s3Object_Version = null; if (cmdletContext.S3Object_Version != null) { requestDocument_document_S3Object_s3Object_Version = cmdletContext.S3Object_Version; } if (requestDocument_document_S3Object_s3Object_Version != null) { requestDocument_document_S3Object.Version = requestDocument_document_S3Object_s3Object_Version; requestDocument_document_S3ObjectIsNull = false; } // determine if requestDocument_document_S3Object should be set to null if (requestDocument_document_S3ObjectIsNull) { requestDocument_document_S3Object = null; } if (requestDocument_document_S3Object != null) { request.Document.S3Object = requestDocument_document_S3Object; requestDocumentIsNull = false; } // determine if request.Document should be set to null if (requestDocumentIsNull) { request.Document = null; } if (cmdletContext.FeatureType != null) { request.FeatureTypes = cmdletContext.FeatureType; } // populate HumanLoopConfig var requestHumanLoopConfigIsNull = true; request.HumanLoopConfig = new Amazon.Textract.Model.HumanLoopConfig(); System.String requestHumanLoopConfig_humanLoopConfig_FlowDefinitionArn = null; if (cmdletContext.HumanLoopConfig_FlowDefinitionArn != null) { requestHumanLoopConfig_humanLoopConfig_FlowDefinitionArn = cmdletContext.HumanLoopConfig_FlowDefinitionArn; } if (requestHumanLoopConfig_humanLoopConfig_FlowDefinitionArn != null) { request.HumanLoopConfig.FlowDefinitionArn = requestHumanLoopConfig_humanLoopConfig_FlowDefinitionArn; requestHumanLoopConfigIsNull = false; } System.String requestHumanLoopConfig_humanLoopConfig_HumanLoopName = null; if (cmdletContext.HumanLoopConfig_HumanLoopName != null) { requestHumanLoopConfig_humanLoopConfig_HumanLoopName = cmdletContext.HumanLoopConfig_HumanLoopName; } if (requestHumanLoopConfig_humanLoopConfig_HumanLoopName != null) { request.HumanLoopConfig.HumanLoopName = requestHumanLoopConfig_humanLoopConfig_HumanLoopName; requestHumanLoopConfigIsNull = false; } Amazon.Textract.Model.HumanLoopDataAttributes requestHumanLoopConfig_humanLoopConfig_DataAttributes = null; // populate DataAttributes var requestHumanLoopConfig_humanLoopConfig_DataAttributesIsNull = true; requestHumanLoopConfig_humanLoopConfig_DataAttributes = new Amazon.Textract.Model.HumanLoopDataAttributes(); List <System.String> requestHumanLoopConfig_humanLoopConfig_DataAttributes_dataAttributes_ContentClassifier = null; if (cmdletContext.DataAttributes_ContentClassifier != null) { requestHumanLoopConfig_humanLoopConfig_DataAttributes_dataAttributes_ContentClassifier = cmdletContext.DataAttributes_ContentClassifier; } if (requestHumanLoopConfig_humanLoopConfig_DataAttributes_dataAttributes_ContentClassifier != null) { requestHumanLoopConfig_humanLoopConfig_DataAttributes.ContentClassifiers = requestHumanLoopConfig_humanLoopConfig_DataAttributes_dataAttributes_ContentClassifier; requestHumanLoopConfig_humanLoopConfig_DataAttributesIsNull = false; } // determine if requestHumanLoopConfig_humanLoopConfig_DataAttributes should be set to null if (requestHumanLoopConfig_humanLoopConfig_DataAttributesIsNull) { requestHumanLoopConfig_humanLoopConfig_DataAttributes = null; } if (requestHumanLoopConfig_humanLoopConfig_DataAttributes != null) { request.HumanLoopConfig.DataAttributes = requestHumanLoopConfig_humanLoopConfig_DataAttributes; requestHumanLoopConfigIsNull = false; } // determine if request.HumanLoopConfig should be set to null if (requestHumanLoopConfigIsNull) { request.HumanLoopConfig = 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); } finally { if (_Document_ByteStream != null) { _Document_ByteStream.Dispose(); } } }