public void TranslateTextMarshallTest() { var request = InstantiateClassGenerator.Execute <TranslateTextRequest>(); var marshaller = new TranslateTextRequestMarshaller(); var internalRequest = marshaller.Marshall(request); var jsonRequest = UTF8Encoding.UTF8.GetString(internalRequest.Content); Comparer.CompareObjectToJson <TranslateTextRequest>(request, jsonRequest); var webResponse = new WebResponseData { Headers = { { "x-amzn-RequestId", Guid.NewGuid().ToString() }, { "x-amz-crc32", "0" } } }; var jsonResponse = new JsonSampleGenerator(service_model, service_model.FindOperation("TranslateText").ResponseStructure).Execute(); webResponse.Headers.Add("Content-Length", UTF8Encoding.UTF8.GetBytes(jsonResponse).Length.ToString()); UnmarshallerContext context = new JsonUnmarshallerContext(Utils.CreateStreamFromString(jsonResponse), false, webResponse); var response = TranslateTextResponseUnmarshaller.Instance.Unmarshall(context) as TranslateTextResponse; InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); }
/// <summary> /// Translates input text from the source language to the target language. You can translate /// between English (en) and one of the following languages, or between one of the following /// languages and English. /// /// <ul> <li> /// <para> /// Arabic (ar) /// </para> /// </li> <li> /// <para> /// Chinese (Simplified) (zh) /// </para> /// </li> <li> /// <para> /// French (fr) /// </para> /// </li> <li> /// <para> /// German (de) /// </para> /// </li> <li> /// <para> /// Portuguese (pt) /// </para> /// </li> <li> /// <para> /// Spanish (es) /// </para> /// </li> </ul> /// </summary> /// <param name="request">Container for the necessary parameters to execute the TranslateText service method.</param> /// /// <returns>The response from the TranslateText service method, as returned by Translate.</returns> /// <exception cref="Amazon.Translate.Model.InternalServerException"> /// An internal server error occurred. Retry your request. /// </exception> /// <exception cref="Amazon.Translate.Model.InvalidRequestException"> /// The request is invalid. /// </exception> /// <exception cref="Amazon.Translate.Model.ServiceUnavailableException"> /// Amazon Translate is unavailable. Retry your request later. /// </exception> /// <exception cref="Amazon.Translate.Model.TextSizeLimitExceededException"> /// The size of the input text exceeds the length constraint for the <code>Text</code> /// field. Try again with a shorter text. /// </exception> /// <exception cref="Amazon.Translate.Model.TooManyRequestsException"> /// The number of requests exceeds the limit. Resubmit your request later. /// </exception> /// <exception cref="Amazon.Translate.Model.UnsupportedLanguagePairException"> /// Amazon Translate cannot translate input text in the source language into this target /// language. For more information, see <a>how-to-error-msg</a>. /// </exception> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/translate-2017-07-01/TranslateText">REST API Reference for TranslateText Operation</seealso> public virtual TranslateTextResponse TranslateText(TranslateTextRequest request) { var marshaller = new TranslateTextRequestMarshaller(); var unmarshaller = TranslateTextResponseUnmarshaller.Instance; return(Invoke <TranslateTextRequest, TranslateTextResponse>(request, marshaller, unmarshaller)); }
/// <summary> /// Initiates the asynchronous execution of the TranslateText operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the TranslateText operation on AmazonTranslateClient.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndTranslateText /// operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/translate-2017-07-01/TranslateText">REST API Reference for TranslateText Operation</seealso> public virtual IAsyncResult BeginTranslateText(TranslateTextRequest request, AsyncCallback callback, object state) { var marshaller = new TranslateTextRequestMarshaller(); var unmarshaller = TranslateTextResponseUnmarshaller.Instance; return(BeginInvoke <TranslateTextRequest>(request, marshaller, unmarshaller, callback, state)); }
/// <summary> /// Initiates the asynchronous execution of the TranslateText operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the TranslateText operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/translate-2017-07-01/TranslateText">REST API Reference for TranslateText Operation</seealso> public virtual Task <TranslateTextResponse> TranslateTextAsync(TranslateTextRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new TranslateTextRequestMarshaller(); var unmarshaller = TranslateTextResponseUnmarshaller.Instance; return(InvokeAsync <TranslateTextRequest, TranslateTextResponse>(request, marshaller, unmarshaller, cancellationToken)); }