/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ /* * Do not modify this file. This file is generated from the runtime.lex.v2-2020-08-07.normal.json service model. */ using System; using System.Runtime.ExceptionServices; using System.Threading; using System.Threading.Tasks; using System.Collections.Generic; using System.Net; using Amazon.LexRuntimeV2.Model; using Amazon.LexRuntimeV2.Model.Internal.MarshallTransformations; using Amazon.LexRuntimeV2.Internal; using Amazon.Runtime; using Amazon.Runtime.Internal; using Amazon.Runtime.Internal.Auth; using Amazon.Runtime.Internal.Transform; namespace Amazon.LexRuntimeV2 { /// /// Implementation for accessing LexRuntimeV2 /// /// This section contains documentation for the Amazon Lex V2 Runtime V2 API operations. /// public partial class AmazonLexRuntimeV2Client : AmazonServiceClient, IAmazonLexRuntimeV2 { private static IServiceMetadata serviceMetadata = new AmazonLexRuntimeV2Metadata(); #region Constructors /// /// Constructs AmazonLexRuntimeV2Client with the credentials loaded from the application's /// default configuration, and if unsuccessful from the Instance Profile service on an EC2 instance. /// /// Example App.config with credentials set. /// /// <?xml version="1.0" encoding="utf-8" ?> /// <configuration> /// <appSettings> /// <add key="AWSProfileName" value="AWS Default"/> /// </appSettings> /// </configuration> /// /// /// public AmazonLexRuntimeV2Client() : base(FallbackCredentialsFactory.GetCredentials(), new AmazonLexRuntimeV2Config()) { } /// /// Constructs AmazonLexRuntimeV2Client with the credentials loaded from the application's /// default configuration, and if unsuccessful from the Instance Profile service on an EC2 instance. /// /// Example App.config with credentials set. /// /// <?xml version="1.0" encoding="utf-8" ?> /// <configuration> /// <appSettings> /// <add key="AWSProfileName" value="AWS Default"/> /// </appSettings> /// </configuration> /// /// /// /// The region to connect. public AmazonLexRuntimeV2Client(RegionEndpoint region) : base(FallbackCredentialsFactory.GetCredentials(), new AmazonLexRuntimeV2Config{RegionEndpoint = region}) { } /// /// Constructs AmazonLexRuntimeV2Client with the credentials loaded from the application's /// default configuration, and if unsuccessful from the Instance Profile service on an EC2 instance. /// /// Example App.config with credentials set. /// /// <?xml version="1.0" encoding="utf-8" ?> /// <configuration> /// <appSettings> /// <add key="AWSProfileName" value="AWS Default"/> /// </appSettings> /// </configuration> /// /// /// /// The AmazonLexRuntimeV2Client Configuration Object public AmazonLexRuntimeV2Client(AmazonLexRuntimeV2Config config) : base(FallbackCredentialsFactory.GetCredentials(config), config){} /// /// Constructs AmazonLexRuntimeV2Client with AWS Credentials /// /// AWS Credentials public AmazonLexRuntimeV2Client(AWSCredentials credentials) : this(credentials, new AmazonLexRuntimeV2Config()) { } /// /// Constructs AmazonLexRuntimeV2Client with AWS Credentials /// /// AWS Credentials /// The region to connect. public AmazonLexRuntimeV2Client(AWSCredentials credentials, RegionEndpoint region) : this(credentials, new AmazonLexRuntimeV2Config{RegionEndpoint = region}) { } /// /// Constructs AmazonLexRuntimeV2Client with AWS Credentials and an /// AmazonLexRuntimeV2Client Configuration object. /// /// AWS Credentials /// The AmazonLexRuntimeV2Client Configuration Object public AmazonLexRuntimeV2Client(AWSCredentials credentials, AmazonLexRuntimeV2Config clientConfig) : base(credentials, clientConfig) { } /// /// Constructs AmazonLexRuntimeV2Client with AWS Access Key ID and AWS Secret Key /// /// AWS Access Key ID /// AWS Secret Access Key public AmazonLexRuntimeV2Client(string awsAccessKeyId, string awsSecretAccessKey) : this(awsAccessKeyId, awsSecretAccessKey, new AmazonLexRuntimeV2Config()) { } /// /// Constructs AmazonLexRuntimeV2Client with AWS Access Key ID and AWS Secret Key /// /// AWS Access Key ID /// AWS Secret Access Key /// The region to connect. public AmazonLexRuntimeV2Client(string awsAccessKeyId, string awsSecretAccessKey, RegionEndpoint region) : this(awsAccessKeyId, awsSecretAccessKey, new AmazonLexRuntimeV2Config() {RegionEndpoint=region}) { } /// /// Constructs AmazonLexRuntimeV2Client with AWS Access Key ID, AWS Secret Key and an /// AmazonLexRuntimeV2Client Configuration object. /// /// AWS Access Key ID /// AWS Secret Access Key /// The AmazonLexRuntimeV2Client Configuration Object public AmazonLexRuntimeV2Client(string awsAccessKeyId, string awsSecretAccessKey, AmazonLexRuntimeV2Config clientConfig) : base(awsAccessKeyId, awsSecretAccessKey, clientConfig) { } /// /// Constructs AmazonLexRuntimeV2Client with AWS Access Key ID and AWS Secret Key /// /// AWS Access Key ID /// AWS Secret Access Key /// AWS Session Token public AmazonLexRuntimeV2Client(string awsAccessKeyId, string awsSecretAccessKey, string awsSessionToken) : this(awsAccessKeyId, awsSecretAccessKey, awsSessionToken, new AmazonLexRuntimeV2Config()) { } /// /// Constructs AmazonLexRuntimeV2Client with AWS Access Key ID and AWS Secret Key /// /// AWS Access Key ID /// AWS Secret Access Key /// AWS Session Token /// The region to connect. public AmazonLexRuntimeV2Client(string awsAccessKeyId, string awsSecretAccessKey, string awsSessionToken, RegionEndpoint region) : this(awsAccessKeyId, awsSecretAccessKey, awsSessionToken, new AmazonLexRuntimeV2Config{RegionEndpoint = region}) { } /// /// Constructs AmazonLexRuntimeV2Client with AWS Access Key ID, AWS Secret Key and an /// AmazonLexRuntimeV2Client Configuration object. /// /// AWS Access Key ID /// AWS Secret Access Key /// AWS Session Token /// The AmazonLexRuntimeV2Client Configuration Object public AmazonLexRuntimeV2Client(string awsAccessKeyId, string awsSecretAccessKey, string awsSessionToken, AmazonLexRuntimeV2Config clientConfig) : base(awsAccessKeyId, awsSecretAccessKey, awsSessionToken, clientConfig) { } #endregion #region Overrides /// /// Creates the signer for the service. /// protected override AbstractAWSSigner CreateSigner() { return new AWS4Signer(); } /// /// Customizes the runtime pipeline. /// /// Runtime pipeline for the current client. protected override void CustomizeRuntimePipeline(RuntimePipeline pipeline) { pipeline.RemoveHandler(); pipeline.AddHandlerAfter(new AmazonLexRuntimeV2EndpointResolver()); } /// /// Capture metadata for the service. /// protected override IServiceMetadata ServiceMetadata { get { return serviceMetadata; } } #endregion #region Dispose /// /// Disposes the service client. /// protected override void Dispose(bool disposing) { base.Dispose(disposing); } #endregion #region DeleteSession internal virtual DeleteSessionResponse DeleteSession(DeleteSessionRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = DeleteSessionRequestMarshaller.Instance; options.ResponseUnmarshaller = DeleteSessionResponseUnmarshaller.Instance; return Invoke(request, options); } /// /// Removes session information for a specified bot, alias, and user ID. /// /// /// /// You can use this operation to restart a conversation with a bot. When you remove a /// session, the entire history of the session is removed so that you can start again. /// /// /// /// You don't need to delete a session. Sessions have a time limit and will expire. Set /// the session time limit when you create the bot. The default is 5 minutes, but you /// can specify anything between 1 minute and 24 hours. /// /// /// /// If you specify a bot or alias ID that doesn't exist, you receive a BadRequestException. /// /// /// /// /// If the locale doesn't exist in the bot, or if the locale hasn't been enables for the /// alias, you receive a BadRequestException. /// /// /// Container for the necessary parameters to execute the DeleteSession service method. /// /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// /// /// The response from the DeleteSession service method, as returned by LexRuntimeV2. /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// REST API Reference for DeleteSession Operation public virtual Task DeleteSessionAsync(DeleteSessionRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = DeleteSessionRequestMarshaller.Instance; options.ResponseUnmarshaller = DeleteSessionResponseUnmarshaller.Instance; return InvokeAsync(request, options, cancellationToken); } #endregion #region GetSession internal virtual GetSessionResponse GetSession(GetSessionRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = GetSessionRequestMarshaller.Instance; options.ResponseUnmarshaller = GetSessionResponseUnmarshaller.Instance; return Invoke(request, options); } /// /// Returns session information for a specified bot, alias, and user. /// /// /// /// For example, you can use this operation to retrieve session information for a user /// that has left a long-running session in use. /// /// /// /// If the bot, alias, or session identifier doesn't exist, Amazon Lex V2 returns a BadRequestException. /// If the locale doesn't exist or is not enabled for the alias, you receive a BadRequestException. /// /// /// Container for the necessary parameters to execute the GetSession service method. /// /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// /// /// The response from the GetSession service method, as returned by LexRuntimeV2. /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// REST API Reference for GetSession Operation public virtual Task GetSessionAsync(GetSessionRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = GetSessionRequestMarshaller.Instance; options.ResponseUnmarshaller = GetSessionResponseUnmarshaller.Instance; return InvokeAsync(request, options, cancellationToken); } #endregion #region PutSession internal virtual PutSessionResponse PutSession(PutSessionRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = PutSessionRequestMarshaller.Instance; options.ResponseUnmarshaller = PutSessionResponseUnmarshaller.Instance; return Invoke(request, options); } /// /// Creates a new session or modifies an existing session with an Amazon Lex V2 bot. Use /// this operation to enable your application to set the state of the bot. /// /// Container for the necessary parameters to execute the PutSession service method. /// /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// /// /// The response from the PutSession service method, as returned by LexRuntimeV2. /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// REST API Reference for PutSession Operation public virtual Task PutSessionAsync(PutSessionRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = PutSessionRequestMarshaller.Instance; options.ResponseUnmarshaller = PutSessionResponseUnmarshaller.Instance; return InvokeAsync(request, options, cancellationToken); } #endregion #region RecognizeText internal virtual RecognizeTextResponse RecognizeText(RecognizeTextRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = RecognizeTextRequestMarshaller.Instance; options.ResponseUnmarshaller = RecognizeTextResponseUnmarshaller.Instance; return Invoke(request, options); } /// /// Sends user input to Amazon Lex V2. Client applications use this API to send requests /// to Amazon Lex V2 at runtime. Amazon Lex V2 then interprets the user input using the /// machine learning model that it build for the bot. /// /// /// /// In response, Amazon Lex V2 returns the next message to convey to the user and an optional /// response card to display. /// /// /// /// If the optional post-fulfillment response is specified, the messages are returned /// as follows. For more information, see PostFulfillmentStatusSpecification. /// ///
  • /// /// Success message - Returned if the Lambda function completes successfully and /// the intent state is fulfilled or ready fulfillment if the message is present. /// ///
  • /// /// Failed message - The failed message is returned if the Lambda function throws /// an exception or if the Lambda function returns a failed intent state without a message. /// ///
  • /// /// Timeout message - If you don't configure a timeout message and a timeout, /// and the Lambda function doesn't return within 30 seconds, the timeout message is returned. /// If you configure a timeout, the timeout message is returned when the period times /// out. /// ///
/// /// For more information, see Completion /// message. /// ///
/// Container for the necessary parameters to execute the RecognizeText service method. /// /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// /// /// The response from the RecognizeText service method, as returned by LexRuntimeV2. /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// REST API Reference for RecognizeText Operation public virtual Task RecognizeTextAsync(RecognizeTextRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = RecognizeTextRequestMarshaller.Instance; options.ResponseUnmarshaller = RecognizeTextResponseUnmarshaller.Instance; return InvokeAsync(request, options, cancellationToken); } #endregion #region RecognizeUtterance internal virtual RecognizeUtteranceResponse RecognizeUtterance(RecognizeUtteranceRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = RecognizeUtteranceRequestMarshaller.Instance; options.ResponseUnmarshaller = RecognizeUtteranceResponseUnmarshaller.Instance; return Invoke(request, options); } /// /// Sends user input to Amazon Lex V2. You can send text or speech. Clients use this API /// to send text and audio requests to Amazon Lex V2 at runtime. Amazon Lex V2 interprets /// the user input using the machine learning model built for the bot. /// /// /// /// The following request fields must be compressed with gzip and then base64 encoded /// before you send them to Amazon Lex V2. /// ///
  • /// /// requestAttributes /// ///
  • /// /// sessionState /// ///
/// /// The following response fields are compressed using gzip and then base64 encoded by /// Amazon Lex V2. Before you can use these fields, you must decode and decompress them. /// /// ///
  • /// /// inputTranscript /// ///
  • /// /// interpretations /// ///
  • /// /// messages /// ///
  • /// /// requestAttributes /// ///
  • /// /// sessionState /// ///
/// /// The example contains a Java application that compresses and encodes a Java object /// to send to Amazon Lex V2, and a second that decodes and decompresses a response from /// Amazon Lex V2. /// /// /// /// If the optional post-fulfillment response is specified, the messages are returned /// as follows. For more information, see PostFulfillmentStatusSpecification. /// ///
  • /// /// Success message - Returned if the Lambda function completes successfully and /// the intent state is fulfilled or ready fulfillment if the message is present. /// ///
  • /// /// Failed message - The failed message is returned if the Lambda function throws /// an exception or if the Lambda function returns a failed intent state without a message. /// ///
  • /// /// Timeout message - If you don't configure a timeout message and a timeout, /// and the Lambda function doesn't return within 30 seconds, the timeout message is returned. /// If you configure a timeout, the timeout message is returned when the period times /// out. /// ///
/// /// For more information, see Completion /// message. /// ///
/// Container for the necessary parameters to execute the RecognizeUtterance service method. /// /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// /// /// The response from the RecognizeUtterance service method, as returned by LexRuntimeV2. /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// REST API Reference for RecognizeUtterance Operation public virtual Task RecognizeUtteranceAsync(RecognizeUtteranceRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = RecognizeUtteranceRequestMarshaller.Instance; options.ResponseUnmarshaller = RecognizeUtteranceResponseUnmarshaller.Instance; return InvokeAsync(request, options, cancellationToken); } #endregion } }