diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/Azure.AI.Language.QuestionAnswering.Authoring.sln b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/Azure.AI.Language.QuestionAnswering.Authoring.sln new file mode 100644 index 000000000000..6ff8ce78eddb --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/Azure.AI.Language.QuestionAnswering.Authoring.sln @@ -0,0 +1,56 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{ECC730C1-4AEA-420C-916A-66B19B79E4DC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.Language.QuestionAnswering.Authoring", "src\Azure.AI.Language.QuestionAnswering.Authoring.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.Language.QuestionAnswering.Authoring.Tests", "tests\Azure.AI.Language.QuestionAnswering.Authoring.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/CHANGELOG.md b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/CHANGELOG.md new file mode 100644 index 000000000000..8b33f0fedccc --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes \ No newline at end of file diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/Directory.Build.props b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/README.md b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/README.md new file mode 100644 index 000000000000..87e7ca03f86a --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/README.md @@ -0,0 +1,107 @@ +# Azure.AI.Language.QuestionAnswering.Authoring client library for .NET + +Azure.AI.Language.QuestionAnswering.Authoring is a managed service that helps developers get secret simply and securely. + +Use the client library for to: + +* [Get secret](https://docs.microsoft.com/azure) + +[Source code][source_root] | [Package (NuGet)][package] | [API reference documentation][reference_docs] | [Product documentation][azconfig_docs] | [Samples][source_samples] + + [Source code](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src) | [Package (NuGet)](https://www.nuget.org/packages) | [API reference documentation](https://azure.github.io/azure-sdk-for-net) | [Product documentation](https://docs.microsoft.com/azure) + +## Getting started + +This section should include everything a developer needs to do to install and create their first client connection *very quickly*. + +### Install the package + +First, provide instruction for obtaining and installing the package or library. This section might include only a single line of code, like `dotnet add package package-name`, but should enable a developer to successfully install the package from NuGet, npm, or even cloning a GitHub repository. + +Install the client library for .NET with [NuGet](https://www.nuget.org/ ): + +```dotnetcli +dotnet add package Azure.AI.Language.QuestionAnswering.Authoring --prerelease +``` + +### Prerequisites + +Include a section after the install command that details any requirements that must be satisfied before a developer can [authenticate](#authenticate-the-client) and test all of the snippets in the [Examples](#examples) section. For example, for Cosmos DB: + +> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/) and [Cosmos DB account](https://docs.microsoft.com/azure/cosmos-db/account-overview) (SQL API). In order to take advantage of the C# 8.0 syntax, it is recommended that you compile using the [.NET Core SDK](https://dotnet.microsoft.com/download) 3.0 or higher with a [language version](https://docs.microsoft.com/dotnet/csharp/language-reference/configure-language-version#override-a-default) of `latest`. It is also possible to compile with the .NET Core SDK 2.1.x using a language version of `preview`. + +### Authenticate the client + +If your library requires authentication for use, such as for Azure services, include instructions and example code needed for initializing and authenticating. + +For example, include details on obtaining an account key and endpoint URI, setting environment variables for each, and initializing the client object. + +### Service API versions + +The client library targets the latest service API version by default. A client instance accepts an optional service API version parameter from its options to specify which API version service to communicate. + +#### Select a service API version + +You have the flexibility to explicitly select a supported service API version when instantiating a client by configuring its associated options. This ensures that the client can communicate with services using the specified API version. + +For example, + +```C# Snippet:CreateClientForSpecificApiVersion +Uri endpoint = new Uri(""); +DefaultAzureCredential credential = new DefaultAzureCredential(); +ClientOptions options = new ClientOptions(ClientOptions.ServiceVersion.) +var client = new Client(endpoint, credential, options); +``` + +When selecting an API version, it's important to verify that there are no breaking changes compared to the latest API version. If there are significant differences, API calls may fail due to incompatibility. + +Always ensure that the chosen API version is fully supported and operational for your specific use case and that it aligns with the service's versioning policy. + +## Key concepts + +The *Key concepts* section should describe the functionality of the main classes. Point out the most important and useful classes in the package (with links to their reference pages) and explain how those classes work together. Feel free to use bulleted lists, tables, code blocks, or even diagrams for clarity. + +Include the *Thread safety* and *Additional concepts* sections below at the end of your *Key concepts* section. You may remove or add links depending on what your library makes use of: + +### Thread safety + +We guarantee that all client instance methods are thread-safe and independent of each other ([guideline](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-service-methods-thread-safety)). This ensures that the recommendation of reusing client instances is always safe, even across threads. + +### Additional concepts + +[Client options](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#configuring-service-clients-using-clientoptions) | +[Accessing the response](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#accessing-http-response-details-using-responset) | +[Long-running operations](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#consuming-long-running-operations-using-operationt) | +[Handling failures](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#reporting-errors-requestfailedexception) | +[Diagnostics](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/Diagnostics.md) | +[Mocking](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#mocking) | +[Client lifetime](https://devblogs.microsoft.com/azure-sdk/lifetime-management-and-thread-safety-guarantees-of-azure-sdk-net-clients/) + + +## Examples + +You can familiarize yourself with different APIs using [Samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/samples). + +## Troubleshooting + +Describe common errors and exceptions, how to "unpack" them if necessary, and include guidance for graceful handling and recovery. + +Provide information to help developers avoid throttling or other service-enforced errors they might encounter. For example, provide guidance and examples for using retry or connection policies in the API. + +If the package or a related package supports it, include tips for logging or enabling instrumentation to help them debug their code. + +## Next steps + +* Provide a link to additional code examples, ideally to those sitting alongside the README in the package's `/samples` directory. +* If appropriate, point users to other packages that might be useful. +* If you think there's a good chance that developers might stumble across your package in error (because they're searching for specific functionality and mistakenly think the package provides that functionality), point them to the packages they might be looking for. + +## Contributing + +This is a template, but your SDK readme should include details on how to contribute code to the repo/package. + + +[style-guide-msft]: https://docs.microsoft.com/style-guide/capitalization +[style-guide-cloud]: https://aka.ms/azsdk/cloud-style-guide + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-net/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/README.png) \ No newline at end of file diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Azure.AI.Language.QuestionAnswering.Authoring.csproj b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Azure.AI.Language.QuestionAnswering.Authoring.csproj new file mode 100644 index 000000000000..58ba44f482bd --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Azure.AI.Language.QuestionAnswering.Authoring.csproj @@ -0,0 +1,20 @@ + + + This is the Azure.AI.Language.QuestionAnswering.Authoring client library for developing .NET applications with rich experience. + Azure SDK Code Generation Azure.AI.Language.QuestionAnswering.Authoring for Azure Data Plane + 1.0.0-beta.1 + Azure.AI.Language.QuestionAnswering.Authoring + $(RequiredTargetFrameworks) + true + + + + + + + + + + + + diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/AILanguageQuestionAnsweringAuthoringClientBuilderExtensions.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/AILanguageQuestionAnsweringAuthoringClientBuilderExtensions.cs new file mode 100644 index 000000000000..ec2fe64c4fae --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/AILanguageQuestionAnsweringAuthoringClientBuilderExtensions.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.AI.Language.QuestionAnswering.Authoring; +using Azure.Core.Extensions; + +namespace Microsoft.Extensions.Azure +{ + /// Extension methods to add to client builder. + public static partial class AILanguageQuestionAnsweringAuthoringClientBuilderExtensions + { + /// Registers a instance. + /// The builder to register with. + /// Supported Cognitive Services endpoint (e.g., https://<resource-name>.api.cognitiveservices.azure.com). + /// A credential used to authenticate to an Azure Service. + public static IAzureClientBuilder AddAuthoringClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential) + where TBuilder : IAzureClientFactoryBuilder + { + return builder.RegisterClientFactory((options) => new AuthoringClient(endpoint, credential, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// Supported Cognitive Services endpoint (e.g., https://<resource-name>.api.cognitiveservices.azure.com). + public static IAzureClientBuilder AddAuthoringClient(this TBuilder builder, Uri endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential + { + return builder.RegisterClientFactory((options, cred) => new AuthoringClient(endpoint, cred, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddAuthoringClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/AILanguageQuestionAnsweringAuthoringModelFactory.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/AILanguageQuestionAnsweringAuthoringModelFactory.cs new file mode 100644 index 000000000000..53804572806f --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/AILanguageQuestionAnsweringAuthoringModelFactory.cs @@ -0,0 +1,377 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Model factory for models. + public static partial class AILanguageQuestionAnsweringAuthoringModelFactory + { + /// Initializes a new instance of . + /// Name of the project. + /// Description of the project. + /// + /// Language of the text records. This is BCP-47 representation of a language. For + /// example, use "en" for English; "es" for Spanish etc. If not set, use "en" for + /// English as default. + /// + /// Resource enabled for multiple languages across projects or not. + /// Configurable settings of the Project. + /// Project creation date-time. + /// Represents the project last modified date-time. + /// Represents the project last deployment date-time. + /// A new instance for mocking. + public static ProjectMetadata ProjectMetadata(string projectName = null, string description = null, string language = null, bool? multilingualResource = null, ProjectSettings settings = null, DateTimeOffset? createdDateTime = null, DateTimeOffset? lastModifiedDateTime = null, DateTimeOffset? lastDeployedDateTime = null) + { + return new ProjectMetadata( + projectName, + description, + language, + multilingualResource, + settings, + createdDateTime, + lastModifiedDateTime, + lastDeployedDateTime, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// One of a server-defined set of error codes. + /// A human-readable representation of the error. + /// The target of the error. + /// An array of details about specific errors that led to this reported error. + /// + /// An object containing more specific information than the current object about + /// the error. + /// + /// A new instance for mocking. + public static Error Error(ErrorCode code = default, string message = null, string target = null, IEnumerable details = null, InnerErrorModel innererror = null) + { + details ??= new List(); + + return new Error( + code, + message, + target, + details?.ToList(), + innererror, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// One of a server-defined set of error codes. + /// Error message. + /// Error details. + /// Error target. + /// + /// An object containing more specific information than the current object about + /// the error. + /// + /// A new instance for mocking. + public static InnerErrorModel InnerErrorModel(InnerErrorCode code = default, string message = null, IReadOnlyDictionary details = null, string target = null, InnerErrorModel innererror = null) + { + details ??= new Dictionary(); + + return new InnerErrorModel( + code, + message, + details, + target, + innererror, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Description of the project. + /// + /// Language of the text records. This is BCP-47 representation of a language. For + /// example, use "en" for English; "es" for Spanish etc. If not set, use "en" for + /// English as default. + /// + /// + /// Set to true to enable creating knowledgebases in different languages for the + /// same resource. + /// + /// Configurable settings of the Project. + /// A new instance for mocking. + public static CreateProjectOptions CreateProjectOptions(string description = null, string language = null, bool? multilingualResource = null, ProjectSettings settings = null) + { + return new CreateProjectOptions(description, language, multilingualResource, settings, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The creation date time of the job. + /// The expiration date time of the job. + /// The job ID. + /// The last date time the job was updated. + /// Job Status. + /// The errors encountered while executing the job. + /// A new instance for mocking. + public static QuestionAnsweringAuthoringProjectDeletionJobState QuestionAnsweringAuthoringProjectDeletionJobState(DateTimeOffset createdDateTime = default, DateTimeOffset? expirationDateTime = null, string jobId = null, DateTimeOffset lastUpdatedDateTime = default, JobStatus status = default, IEnumerable errors = null) + { + errors ??= new List(); + + return new QuestionAnsweringAuthoringProjectDeletionJobState( + createdDateTime, + expirationDateTime, + jobId, + lastUpdatedDateTime, + status, + errors?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The creation date time of the job. + /// The expiration date time of the job. + /// The job ID. + /// The last date time the job was updated. + /// Job Status. + /// The errors encountered while executing the job. + /// URL to download the result of the Export Job. + /// A new instance for mocking. + public static QuestionAnsweringAuthoringExportJobState QuestionAnsweringAuthoringExportJobState(DateTimeOffset createdDateTime = default, DateTimeOffset? expirationDateTime = null, string jobId = null, DateTimeOffset lastUpdatedDateTime = default, JobStatus status = default, IEnumerable errors = null, string resultUrl = null) + { + errors ??= new List(); + + return new QuestionAnsweringAuthoringExportJobState( + createdDateTime, + expirationDateTime, + jobId, + lastUpdatedDateTime, + status, + errors?.ToList(), + resultUrl, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Unique ID for the QnA. + /// Answer text. + /// + /// Source from which QnA was indexed e.g. + /// https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs . + /// + /// List of questions associated with the answer. + /// + /// Metadata associated with the answer, useful to categorize or filter question + /// answers. + /// + /// Context of a QnA. + /// List of Active Learning suggestions for the QnA. + /// Date-time when the QnA was last updated. + /// Friendly name of the Source. + /// A new instance for mocking. + public static ImportQnaRecord ImportQnaRecord(int id = default, string answer = null, string source = null, IEnumerable questions = null, IDictionary metadata = null, QnaDialog dialog = null, IEnumerable activeLearningSuggestions = null, DateTimeOffset? lastUpdatedDateTime = null, string sourceDisplayName = null) + { + questions ??= new List(); + metadata ??= new Dictionary(); + activeLearningSuggestions ??= new List(); + + return new ImportQnaRecord( + id, + answer, + source, + questions?.ToList(), + metadata, + dialog, + activeLearningSuggestions?.ToList(), + lastUpdatedDateTime, + sourceDisplayName, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Unique ID for the QnA. + /// Answer text. + /// + /// Source from which QnA was indexed e.g. + /// https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs . + /// + /// List of questions associated with the answer. + /// + /// Metadata associated with the answer, useful to categorize or filter question + /// answers. + /// + /// Context of a QnA. + /// List of Active Learning suggestions for the QnA. + /// A new instance for mocking. + public static QnaRecord QnaRecord(int id = default, string answer = null, string source = null, IEnumerable questions = null, IDictionary metadata = null, QnaDialog dialog = null, IEnumerable activeLearningSuggestions = null) + { + questions ??= new List(); + metadata ??= new Dictionary(); + activeLearningSuggestions ??= new List(); + + return new QnaRecord( + id, + answer, + source, + questions?.ToList(), + metadata, + dialog, + activeLearningSuggestions?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The creation date time of the job. + /// The expiration date time of the job. + /// The job ID. + /// The last date time the job was updated. + /// Job Status. + /// The errors encountered while executing the job. + /// A new instance for mocking. + public static QuestionAnsweringAuthoringImportJobState QuestionAnsweringAuthoringImportJobState(DateTimeOffset createdDateTime = default, DateTimeOffset? expirationDateTime = null, string jobId = null, DateTimeOffset lastUpdatedDateTime = default, JobStatus status = default, IEnumerable errors = null) + { + errors ??= new List(); + + return new QuestionAnsweringAuthoringImportJobState( + createdDateTime, + expirationDateTime, + jobId, + lastUpdatedDateTime, + status, + errors?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The creation date time of the job. + /// The expiration date time of the job. + /// The job ID. + /// The last date time the job was updated. + /// Job Status. + /// The errors encountered while executing the job. + /// A new instance for mocking. + public static QuestionAnsweringAuthoringProjectDeploymentJobState QuestionAnsweringAuthoringProjectDeploymentJobState(DateTimeOffset createdDateTime = default, DateTimeOffset? expirationDateTime = null, string jobId = null, DateTimeOffset lastUpdatedDateTime = default, JobStatus status = default, IEnumerable errors = null) + { + errors ??= new List(); + + return new QuestionAnsweringAuthoringProjectDeploymentJobState( + createdDateTime, + expirationDateTime, + jobId, + lastUpdatedDateTime, + status, + errors?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Name of the deployment. + /// Represents the project last deployment date-time. + /// A new instance for mocking. + public static ProjectDeployment ProjectDeployment(string deploymentName = null, DateTimeOffset? lastDeployedDateTime = null) + { + return new ProjectDeployment(deploymentName, lastDeployedDateTime, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Friendly name of the Source. + /// + /// Unique source identifier. Name of the file if it's a 'file' source; otherwise, + /// the complete URL if it's a 'url' source. + /// + /// URI location for the file or url. + /// Supported source types. + /// Content structure type for sources. + /// Date-time when the QnA was last updated. + /// A new instance for mocking. + public static QnaSourceRecord QnaSourceRecord(string displayName = null, string source = null, Uri sourceUri = null, SourceKind sourceKind = default, SourceContentStructureKind? contentStructureKind = null, DateTimeOffset? lastUpdatedDateTime = null) + { + return new QnaSourceRecord( + displayName, + source, + sourceUri, + sourceKind, + contentStructureKind, + lastUpdatedDateTime, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The creation date time of the job. + /// The expiration date time of the job. + /// The job ID. + /// The last date time the job was updated. + /// Job Status. + /// The errors encountered while executing the job. + /// A new instance for mocking. + public static QuestionAnsweringAuthoringUpdateSourcesJobState QuestionAnsweringAuthoringUpdateSourcesJobState(DateTimeOffset createdDateTime = default, DateTimeOffset? expirationDateTime = null, string jobId = null, DateTimeOffset lastUpdatedDateTime = default, JobStatus status = default, IEnumerable errors = null) + { + errors ??= new List(); + + return new QuestionAnsweringAuthoringUpdateSourcesJobState( + createdDateTime, + expirationDateTime, + jobId, + lastUpdatedDateTime, + status, + errors?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Unique ID for the QnA. + /// Answer text. + /// + /// Source from which QnA was indexed e.g. + /// https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs . + /// + /// List of questions associated with the answer. + /// + /// Metadata associated with the answer, useful to categorize or filter question + /// answers. + /// + /// Context of a QnA. + /// List of Active Learning suggestions for the QnA. + /// Date-time when the QnA was last updated. + /// A new instance for mocking. + public static RetrieveQnaRecord RetrieveQnaRecord(int id = default, string answer = null, string source = null, IEnumerable questions = null, IReadOnlyDictionary metadata = null, QnaDialog dialog = null, IEnumerable activeLearningSuggestions = null, DateTimeOffset? lastUpdatedDateTime = null) + { + questions ??= new List(); + metadata ??= new Dictionary(); + activeLearningSuggestions ??= new List(); + + return new RetrieveQnaRecord( + id, + answer, + source, + questions?.ToList(), + metadata, + dialog, + activeLearningSuggestions?.ToList(), + lastUpdatedDateTime, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The creation date time of the job. + /// The expiration date time of the job. + /// The job ID. + /// The last date time the job was updated. + /// Job Status. + /// The errors encountered while executing the job. + /// A new instance for mocking. + public static QuestionAnsweringAuthoringUpdateQnasJobState QuestionAnsweringAuthoringUpdateQnasJobState(DateTimeOffset createdDateTime = default, DateTimeOffset? expirationDateTime = null, string jobId = null, DateTimeOffset lastUpdatedDateTime = default, JobStatus status = default, IEnumerable errors = null) + { + errors ??= new List(); + + return new QuestionAnsweringAuthoringUpdateQnasJobState( + createdDateTime, + expirationDateTime, + jobId, + lastUpdatedDateTime, + status, + errors?.ToList(), + serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ActiveLearningFeedback.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ActiveLearningFeedback.Serialization.cs new file mode 100644 index 000000000000..0ff7aeb45b1c --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ActiveLearningFeedback.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class ActiveLearningFeedback : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ActiveLearningFeedback)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Records)) + { + writer.WritePropertyName("records"u8); + writer.WriteStartArray(); + foreach (var item in Records) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ActiveLearningFeedback IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ActiveLearningFeedback)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeActiveLearningFeedback(document.RootElement, options); + } + + internal static ActiveLearningFeedback DeserializeActiveLearningFeedback(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList records = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("records"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(FeedbackRecord.DeserializeFeedbackRecord(item, options)); + } + records = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ActiveLearningFeedback(records ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ActiveLearningFeedback)} does not support writing '{options.Format}' format."); + } + } + + ActiveLearningFeedback IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeActiveLearningFeedback(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ActiveLearningFeedback)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ActiveLearningFeedback FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeActiveLearningFeedback(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ActiveLearningFeedback.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ActiveLearningFeedback.cs new file mode 100644 index 000000000000..da4da9555946 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ActiveLearningFeedback.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Feedback for Active Learning. + public partial class ActiveLearningFeedback + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ActiveLearningFeedback() + { + Records = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// A list of Feedback Records for Active Learning. + /// Keeps track of any properties unknown to the library. + internal ActiveLearningFeedback(IList records, IDictionary serializedAdditionalRawData) + { + Records = records; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// A list of Feedback Records for Active Learning. + public IList Records { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/AssestKind.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/AssestKind.cs new file mode 100644 index 000000000000..fc83abf795f6 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/AssestKind.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Kind of the asset of the project. + public readonly partial struct AssestKind : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AssestKind(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string QnasValue = "qnas"; + private const string SynonymsValue = "synonyms"; + + /// Question and Answers. + public static AssestKind Qnas { get; } = new AssestKind(QnasValue); + /// Synonyms. + public static AssestKind Synonyms { get; } = new AssestKind(SynonymsValue); + /// Determines if two values are the same. + public static bool operator ==(AssestKind left, AssestKind right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AssestKind left, AssestKind right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AssestKind(string value) => new AssestKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AssestKind other && Equals(other); + /// + public bool Equals(AssestKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Assets.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Assets.Serialization.cs new file mode 100644 index 000000000000..c9ad27cde072 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Assets.Serialization.cs @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class Assets : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Assets)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Synonyms)) + { + writer.WritePropertyName("synonyms"u8); + writer.WriteStartArray(); + foreach (var item in Synonyms) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Qnas)) + { + writer.WritePropertyName("qnas"u8); + writer.WriteStartArray(); + foreach (var item in Qnas) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Assets IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Assets)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssets(document.RootElement, options); + } + + internal static Assets DeserializeAssets(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList synonyms = default; + IList qnas = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("synonyms"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(WordAlterations.DeserializeWordAlterations(item, options)); + } + synonyms = array; + continue; + } + if (property.NameEquals("qnas"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ImportQnaRecord.DeserializeImportQnaRecord(item, options)); + } + qnas = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Assets(synonyms ?? new ChangeTrackingList(), qnas ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Assets)} does not support writing '{options.Format}' format."); + } + } + + Assets IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAssets(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Assets)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static Assets FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAssets(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Assets.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Assets.cs new file mode 100644 index 000000000000..dd7c996a382d --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Assets.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// All assets for this project. + public partial class Assets + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public Assets() + { + Synonyms = new ChangeTrackingList(); + Qnas = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Collection of synonyms. + /// List of QnA records to import. + /// Keeps track of any properties unknown to the library. + internal Assets(IList synonyms, IList qnas, IDictionary serializedAdditionalRawData) + { + Synonyms = synonyms; + Qnas = qnas; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Collection of synonyms. + public IList Synonyms { get; } + /// List of QnA records to import. + public IList Qnas { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/AuthoringClient.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/AuthoringClient.cs new file mode 100644 index 000000000000..5ccb2ef1c2c5 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/AuthoringClient.cs @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + // Data plane generated client. + /// + /// The language service API is a suite of natural language processing (NLP) skills + /// built with best-in-class Microsoft machine learning algorithms. The API can be + /// used to analyze unstructured text for tasks such as sentiment analysis, key + /// phrase extraction, language detection and question answering. Further + /// documentation can be found in <a + /// href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview">https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview</a>. + /// + public partial class AuthoringClient + { + private const string AuthorizationHeader = "Ocp-Apim-Subscription-Key"; + private readonly AzureKeyCredential _keyCredential; + private static readonly string[] AuthorizationScopes = new string[] { "https://cognitiveservices.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of AuthoringClient for mocking. + protected AuthoringClient() + { + } + + /// Initializes a new instance of AuthoringClient. + /// Supported Cognitive Services endpoint (e.g., https://<resource-name>.api.cognitiveservices.azure.com). + /// A credential used to authenticate to an Azure Service. + /// or is null. + public AuthoringClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new AuthoringClientOptions()) + { + } + + /// Initializes a new instance of AuthoringClient. + /// Supported Cognitive Services endpoint (e.g., https://<resource-name>.api.cognitiveservices.azure.com). + /// A credential used to authenticate to an Azure Service. + /// or is null. + public AuthoringClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new AuthoringClientOptions()) + { + } + + /// Initializes a new instance of AuthoringClient. + /// Supported Cognitive Services endpoint (e.g., https://<resource-name>.api.cognitiveservices.azure.com). + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public AuthoringClient(Uri endpoint, AzureKeyCredential credential, AuthoringClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new AuthoringClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _keyCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader) }, new ResponseClassifier()); + _endpoint = endpoint; + } + + /// Initializes a new instance of AuthoringClient. + /// Supported Cognitive Services endpoint (e.g., https://<resource-name>.api.cognitiveservices.azure.com). + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public AuthoringClient(Uri endpoint, TokenCredential credential, AuthoringClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new AuthoringClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _tokenCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier()); + _endpoint = endpoint; + } + + /// Initializes a new instance of QuestionAnsweringProjects. + /// The API version to use for this operation. + /// is null. + public virtual QuestionAnsweringProjects GetQuestionAnsweringProjectsClient(string apiVersion = "2023-04-01") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new QuestionAnsweringProjects(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint, apiVersion); + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/AuthoringClientOptions.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/AuthoringClientOptions.cs new file mode 100644 index 000000000000..e0653a6a83fc --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/AuthoringClientOptions.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Client options for AuthoringClient. + public partial class AuthoringClientOptions : ClientOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2023_04_01; + + /// The version of the service to use. + public enum ServiceVersion + { + /// Service version "2023-04-01". + V2023_04_01 = 1, + } + + internal string Version { get; } + + /// Initializes new instance of AuthoringClientOptions. + public AuthoringClientOptions(ServiceVersion version = LatestVersion) + { + Version = version switch + { + ServiceVersion.V2023_04_01 => "2023-04-01", + _ => throw new NotSupportedException() + }; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/CreateProjectOptions.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/CreateProjectOptions.Serialization.cs new file mode 100644 index 000000000000..a55e317c241e --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/CreateProjectOptions.Serialization.cs @@ -0,0 +1,183 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class CreateProjectOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateProjectOptions)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("language"u8); + writer.WriteStringValue(Language); + if (Optional.IsDefined(MultilingualResource)) + { + writer.WritePropertyName("multilingualResource"u8); + writer.WriteBooleanValue(MultilingualResource.Value); + } + if (Optional.IsDefined(Settings)) + { + writer.WritePropertyName("settings"u8); + writer.WriteObjectValue(Settings, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CreateProjectOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateProjectOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateProjectOptions(document.RootElement, options); + } + + internal static CreateProjectOptions DeserializeCreateProjectOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + string language = default; + bool? multilingualResource = default; + ProjectSettings settings = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("language"u8)) + { + language = property.Value.GetString(); + continue; + } + if (property.NameEquals("multilingualResource"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + multilingualResource = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("settings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + settings = ProjectSettings.DeserializeProjectSettings(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CreateProjectOptions(description, language, multilingualResource, settings, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CreateProjectOptions)} does not support writing '{options.Format}' format."); + } + } + + CreateProjectOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateProjectOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateProjectOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CreateProjectOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateProjectOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/CreateProjectOptions.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/CreateProjectOptions.cs new file mode 100644 index 000000000000..f77ace1f3d7b --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/CreateProjectOptions.cs @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Parameters needed to create the project. + public partial class CreateProjectOptions + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// + /// Language of the text records. This is BCP-47 representation of a language. For + /// example, use "en" for English; "es" for Spanish etc. If not set, use "en" for + /// English as default. + /// + /// is null. + public CreateProjectOptions(string language) + { + Argument.AssertNotNull(language, nameof(language)); + + Language = language; + } + + /// Initializes a new instance of . + /// Description of the project. + /// + /// Language of the text records. This is BCP-47 representation of a language. For + /// example, use "en" for English; "es" for Spanish etc. If not set, use "en" for + /// English as default. + /// + /// + /// Set to true to enable creating knowledgebases in different languages for the + /// same resource. + /// + /// Configurable settings of the Project. + /// Keeps track of any properties unknown to the library. + internal CreateProjectOptions(string description, string language, bool? multilingualResource, ProjectSettings settings, IDictionary serializedAdditionalRawData) + { + Description = description; + Language = language; + MultilingualResource = multilingualResource; + Settings = settings; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CreateProjectOptions() + { + } + + /// Description of the project. + public string Description { get; set; } + /// + /// Language of the text records. This is BCP-47 representation of a language. For + /// example, use "en" for English; "es" for Spanish etc. If not set, use "en" for + /// English as default. + /// + public string Language { get; } + /// + /// Set to true to enable creating knowledgebases in different languages for the + /// same resource. + /// + public bool? MultilingualResource { get; set; } + /// Configurable settings of the Project. + public ProjectSettings Settings { get; set; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Docs/QuestionAnsweringAuthoringClient.xml b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Docs/QuestionAnsweringProjects.xml similarity index 58% rename from sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Docs/QuestionAnsweringAuthoringClient.xml rename to sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Docs/QuestionAnsweringProjects.xml index 615c97280772..fcc632b9dfc9 100644 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Docs/QuestionAnsweringAuthoringClient.xml +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Docs/QuestionAnsweringProjects.xml @@ -1,26 +1,64 @@ + + +This sample shows how to call GetProjectDetailsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = await client.GetProjectDetailsAsync(""); +]]> +This sample shows how to call GetProjectDetailsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = await client.GetProjectDetailsAsync(""); +]]> + + + +This sample shows how to call GetProjectDetails. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = client.GetProjectDetails(""); +]]> +This sample shows how to call GetProjectDetails with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = client.GetProjectDetails(""); +]]> + This sample shows how to call GetProjectDetailsAsync and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = await client.GetProjectDetailsAsync(""); +Response response = await client.GetProjectDetailsAsync("", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.ToString()); +Console.WriteLine(result.GetProperty("projectName").ToString()); ]]> This sample shows how to call GetProjectDetailsAsync with all parameters and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = await client.GetProjectDetailsAsync(""); +Response response = await client.GetProjectDetailsAsync("", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("projectName").ToString()); @@ -39,20 +77,20 @@ This sample shows how to call GetProjectDetails and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = client.GetProjectDetails(""); +Response response = client.GetProjectDetails("", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.ToString()); +Console.WriteLine(result.GetProperty("projectName").ToString()); ]]> This sample shows how to call GetProjectDetails with all parameters and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = client.GetProjectDetails(""); +Response response = client.GetProjectDetails("", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("projectName").ToString()); @@ -71,7 +109,7 @@ This sample shows how to call CreateProjectAsync and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new { @@ -80,13 +118,13 @@ using RequestContent content = RequestContent.Create(new Response response = await client.CreateProjectAsync("", content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.ToString()); +Console.WriteLine(result.GetProperty("projectName").ToString()); ]]> This sample shows how to call CreateProjectAsync with all parameters and request content and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new { @@ -117,7 +155,7 @@ This sample shows how to call CreateProject and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new { @@ -126,13 +164,13 @@ using RequestContent content = RequestContent.Create(new Response response = client.CreateProject("", content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.ToString()); +Console.WriteLine(result.GetProperty("projectName").ToString()); ]]> This sample shows how to call CreateProject with all parameters and request content and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new { @@ -155,6 +193,44 @@ Console.WriteLine(result.GetProperty("settings").GetProperty("defaultAnswer").To Console.WriteLine(result.GetProperty("createdDateTime").ToString()); Console.WriteLine(result.GetProperty("lastModifiedDateTime").ToString()); Console.WriteLine(result.GetProperty("lastDeployedDateTime").ToString()); +]]> + + + +This sample shows how to call GetDeleteStatusAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = await client.GetDeleteStatusAsync(""); +]]> +This sample shows how to call GetDeleteStatusAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = await client.GetDeleteStatusAsync(""); +]]> + + + +This sample shows how to call GetDeleteStatus. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = client.GetDeleteStatus(""); +]]> +This sample shows how to call GetDeleteStatus with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = client.GetDeleteStatus(""); ]]> @@ -163,9 +239,9 @@ This sample shows how to call GetDeleteStatusAsync and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = await client.GetDeleteStatusAsync(""); +Response response = await client.GetDeleteStatusAsync("", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("createdDateTime").ToString()); @@ -177,11 +253,16 @@ This sample shows how to call GetDeleteStatusAsync with all parameters and parse "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = await client.GetDeleteStatusAsync(""); +Response response = await client.GetDeleteStatusAsync("", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("createdDateTime").ToString()); +Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); +Console.WriteLine(result.GetProperty("jobId").ToString()); +Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -196,11 +277,6 @@ Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetP Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); ]]> @@ -209,9 +285,9 @@ This sample shows how to call GetDeleteStatus and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = client.GetDeleteStatus(""); +Response response = client.GetDeleteStatus("", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("createdDateTime").ToString()); @@ -223,11 +299,16 @@ This sample shows how to call GetDeleteStatus with all parameters and parse the "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = client.GetDeleteStatus(""); +Response response = client.GetDeleteStatus("", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("createdDateTime").ToString()); +Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); +Console.WriteLine(result.GetProperty("jobId").ToString()); +Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -242,11 +323,44 @@ Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetP Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); +]]> + + + +This sample shows how to call GetExportStatusAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = await client.GetExportStatusAsync("", ""); +]]> +This sample shows how to call GetExportStatusAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = await client.GetExportStatusAsync("", ""); +]]> + + + +This sample shows how to call GetExportStatus. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = client.GetExportStatus("", ""); +]]> +This sample shows how to call GetExportStatus with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = client.GetExportStatus("", ""); ]]> @@ -255,27 +369,31 @@ This sample shows how to call GetExportStatusAsync and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = await client.GetExportStatusAsync("", ""); +Response response = await client.GetExportStatusAsync("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("resultUrl").ToString()); Console.WriteLine(result.GetProperty("createdDateTime").ToString()); Console.WriteLine(result.GetProperty("jobId").ToString()); Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("resultUrl").ToString()); ]]> This sample shows how to call GetExportStatusAsync with all parameters and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = await client.GetExportStatusAsync("", ""); +Response response = await client.GetExportStatusAsync("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("resultUrl").ToString()); +Console.WriteLine(result.GetProperty("createdDateTime").ToString()); +Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); +Console.WriteLine(result.GetProperty("jobId").ToString()); +Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -290,11 +408,7 @@ Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetP Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("resultUrl").ToString()); ]]> @@ -303,27 +417,31 @@ This sample shows how to call GetExportStatus and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = client.GetExportStatus("", ""); +Response response = client.GetExportStatus("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("resultUrl").ToString()); Console.WriteLine(result.GetProperty("createdDateTime").ToString()); Console.WriteLine(result.GetProperty("jobId").ToString()); Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("resultUrl").ToString()); ]]> This sample shows how to call GetExportStatus with all parameters and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = client.GetExportStatus("", ""); +Response response = client.GetExportStatus("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; -Console.WriteLine(result.GetProperty("resultUrl").ToString()); +Console.WriteLine(result.GetProperty("createdDateTime").ToString()); +Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); +Console.WriteLine(result.GetProperty("jobId").ToString()); +Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -338,11 +456,45 @@ Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetP Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("resultUrl").ToString()); +]]> + + + +This sample shows how to call GetImportStatusAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = await client.GetImportStatusAsync("", ""); +]]> +This sample shows how to call GetImportStatusAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = await client.GetImportStatusAsync("", ""); +]]> + + + +This sample shows how to call GetImportStatus. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = client.GetImportStatus("", ""); +]]> +This sample shows how to call GetImportStatus with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = client.GetImportStatus("", ""); ]]> @@ -351,9 +503,9 @@ This sample shows how to call GetImportStatusAsync and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = await client.GetImportStatusAsync("", ""); +Response response = await client.GetImportStatusAsync("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("createdDateTime").ToString()); @@ -365,11 +517,16 @@ This sample shows how to call GetImportStatusAsync with all parameters and parse "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = await client.GetImportStatusAsync("", ""); +Response response = await client.GetImportStatusAsync("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("createdDateTime").ToString()); +Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); +Console.WriteLine(result.GetProperty("jobId").ToString()); +Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -384,11 +541,6 @@ Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetP Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); ]]> @@ -397,9 +549,9 @@ This sample shows how to call GetImportStatus and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = client.GetImportStatus("", ""); +Response response = client.GetImportStatus("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("createdDateTime").ToString()); @@ -411,11 +563,16 @@ This sample shows how to call GetImportStatus with all parameters and parse the "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = client.GetImportStatus("", ""); +Response response = client.GetImportStatus("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("createdDateTime").ToString()); +Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); +Console.WriteLine(result.GetProperty("jobId").ToString()); +Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -430,11 +587,44 @@ Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetP Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); +]]> + + + +This sample shows how to call GetDeployStatusAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = await client.GetDeployStatusAsync("", "", ""); +]]> +This sample shows how to call GetDeployStatusAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = await client.GetDeployStatusAsync("", "", ""); +]]> + + + +This sample shows how to call GetDeployStatus. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = client.GetDeployStatus("", "", ""); +]]> +This sample shows how to call GetDeployStatus with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = client.GetDeployStatus("", "", ""); ]]> @@ -443,9 +633,9 @@ This sample shows how to call GetDeployStatusAsync and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = await client.GetDeployStatusAsync("", "", ""); +Response response = await client.GetDeployStatusAsync("", "", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("createdDateTime").ToString()); @@ -457,11 +647,16 @@ This sample shows how to call GetDeployStatusAsync with all parameters and parse "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = await client.GetDeployStatusAsync("", "", ""); +Response response = await client.GetDeployStatusAsync("", "", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("createdDateTime").ToString()); +Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); +Console.WriteLine(result.GetProperty("jobId").ToString()); +Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -476,11 +671,6 @@ Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetP Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); ]]> @@ -489,9 +679,9 @@ This sample shows how to call GetDeployStatus and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = client.GetDeployStatus("", "", ""); +Response response = client.GetDeployStatus("", "", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("createdDateTime").ToString()); @@ -503,11 +693,16 @@ This sample shows how to call GetDeployStatus with all parameters and parse the "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = client.GetDeployStatus("", "", ""); +Response response = client.GetDeployStatus("", "", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("createdDateTime").ToString()); +Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); +Console.WriteLine(result.GetProperty("jobId").ToString()); +Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -522,69 +717,75 @@ Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetP Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); ]]> - + This sample shows how to call UpdateSynonymsAsync. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); - -using RequestContent content = RequestContent.Create(new object()); -Response response = await client.UpdateSynonymsAsync("", content); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Console.WriteLine(response.Status); +SynonymAssets body = new SynonymAssets(new WordAlterations[] +{ + new WordAlterations(new string[]{""}) +}); +Response response = await client.UpdateSynonymsAsync("", body); ]]> -This sample shows how to call UpdateSynonymsAsync with all parameters and request content. +This sample shows how to call UpdateSynonymsAsync with all parameters. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -using RequestContent content = RequestContent.Create(new +SynonymAssets body = new SynonymAssets(new WordAlterations[] { - value = new object[] - { - new - { - alterations = new object[] - { - "" - }, - } - }, - nextLink = "", -}); -Response response = await client.UpdateSynonymsAsync("", content); - -Console.WriteLine(response.Status); + new WordAlterations(new string[]{""}) +}) +{ + NextLink = new Uri("http://localhost:3000"), +}; +Response response = await client.UpdateSynonymsAsync("", body); ]]> - + This sample shows how to call UpdateSynonyms. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); - -using RequestContent content = RequestContent.Create(new object()); -Response response = client.UpdateSynonyms("", content); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Console.WriteLine(response.Status); +SynonymAssets body = new SynonymAssets(new WordAlterations[] +{ + new WordAlterations(new string[]{""}) +}); +Response response = client.UpdateSynonyms("", body); ]]> -This sample shows how to call UpdateSynonyms with all parameters and request content. +This sample shows how to call UpdateSynonyms with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +SynonymAssets body = new SynonymAssets(new WordAlterations[] +{ + new WordAlterations(new string[]{""}) +}) +{ + NextLink = new Uri("http://localhost:3000"), +}; +Response response = client.UpdateSynonyms("", body); +]]> + + + +This sample shows how to call UpdateSynonymsAsync. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new { @@ -598,11 +799,122 @@ using RequestContent content = RequestContent.Create(new }, } }, - nextLink = "", }); -Response response = client.UpdateSynonyms("", content); +Response response = await client.UpdateSynonymsAsync("", content); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call UpdateSynonymsAsync with all parameters and request content. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +using RequestContent content = RequestContent.Create(new +{ + value = new object[] + { + new + { + alterations = new object[] + { + "" + }, + } + }, + nextLink = "http://localhost:3000", +}); +Response response = await client.UpdateSynonymsAsync("", content); Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call UpdateSynonyms. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +using RequestContent content = RequestContent.Create(new +{ + value = new object[] + { + new + { + alterations = new object[] + { + "" + }, + } + }, +}); +Response response = client.UpdateSynonyms("", content); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call UpdateSynonyms with all parameters and request content. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +using RequestContent content = RequestContent.Create(new +{ + value = new object[] + { + new + { + alterations = new object[] + { + "" + }, + } + }, + nextLink = "http://localhost:3000", +}); +Response response = client.UpdateSynonyms("", content); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call GetUpdateSourcesStatusAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = await client.GetUpdateSourcesStatusAsync("", ""); +]]> +This sample shows how to call GetUpdateSourcesStatusAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = await client.GetUpdateSourcesStatusAsync("", ""); +]]> + + + +This sample shows how to call GetUpdateSourcesStatus. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = client.GetUpdateSourcesStatus("", ""); +]]> +This sample shows how to call GetUpdateSourcesStatus with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = client.GetUpdateSourcesStatus("", ""); ]]> @@ -611,9 +923,9 @@ This sample shows how to call GetUpdateSourcesStatusAsync and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = await client.GetUpdateSourcesStatusAsync("", ""); +Response response = await client.GetUpdateSourcesStatusAsync("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("createdDateTime").ToString()); @@ -625,11 +937,16 @@ This sample shows how to call GetUpdateSourcesStatusAsync with all parameters an "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = await client.GetUpdateSourcesStatusAsync("", ""); +Response response = await client.GetUpdateSourcesStatusAsync("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("createdDateTime").ToString()); +Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); +Console.WriteLine(result.GetProperty("jobId").ToString()); +Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -644,11 +961,6 @@ Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetP Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); ]]> @@ -657,9 +969,9 @@ This sample shows how to call GetUpdateSourcesStatus and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = client.GetUpdateSourcesStatus("", ""); +Response response = client.GetUpdateSourcesStatus("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("createdDateTime").ToString()); @@ -671,11 +983,16 @@ This sample shows how to call GetUpdateSourcesStatus with all parameters and par "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = client.GetUpdateSourcesStatus("", ""); +Response response = client.GetUpdateSourcesStatus("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("createdDateTime").ToString()); +Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); +Console.WriteLine(result.GetProperty("jobId").ToString()); +Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -690,11 +1007,44 @@ Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetP Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); +]]> + + + +This sample shows how to call GetUpdateQnasStatusAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = await client.GetUpdateQnasStatusAsync("", ""); +]]> +This sample shows how to call GetUpdateQnasStatusAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = await client.GetUpdateQnasStatusAsync("", ""); +]]> + + + +This sample shows how to call GetUpdateQnasStatus. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = client.GetUpdateQnasStatus("", ""); +]]> +This sample shows how to call GetUpdateQnasStatus with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Response response = client.GetUpdateQnasStatus("", ""); ]]> @@ -703,9 +1053,9 @@ This sample shows how to call GetUpdateQnasStatusAsync and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = await client.GetUpdateQnasStatusAsync("", ""); +Response response = await client.GetUpdateQnasStatusAsync("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("createdDateTime").ToString()); @@ -717,11 +1067,16 @@ This sample shows how to call GetUpdateQnasStatusAsync with all parameters and p "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = await client.GetUpdateQnasStatusAsync("", ""); +Response response = await client.GetUpdateQnasStatusAsync("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("createdDateTime").ToString()); +Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); +Console.WriteLine(result.GetProperty("jobId").ToString()); +Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -736,11 +1091,6 @@ Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetP Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); ]]> @@ -749,9 +1099,9 @@ This sample shows how to call GetUpdateQnasStatus and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = client.GetUpdateQnasStatus("", ""); +Response response = client.GetUpdateQnasStatus("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("createdDateTime").ToString()); @@ -763,11 +1113,16 @@ This sample shows how to call GetUpdateQnasStatus with all parameters and parse "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Response response = client.GetUpdateQnasStatus("", ""); +Response response = client.GetUpdateQnasStatus("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("createdDateTime").ToString()); +Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); +Console.WriteLine(result.GetProperty("jobId").ToString()); +Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -782,11 +1137,64 @@ Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetP Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); +]]> + + + +This sample shows how to call AddFeedbackAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +ActiveLearningFeedback body = new ActiveLearningFeedback(); +Response response = await client.AddFeedbackAsync("", body); +]]> +This sample shows how to call AddFeedbackAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +ActiveLearningFeedback body = new ActiveLearningFeedback +{ + Records = {new FeedbackRecord + { + UserId = "", + UserQuestion = "", + QnaId = 1234, + }}, +}; +Response response = await client.AddFeedbackAsync("", body); +]]> + + + +This sample shows how to call AddFeedback. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +ActiveLearningFeedback body = new ActiveLearningFeedback(); +Response response = client.AddFeedback("", body); +]]> +This sample shows how to call AddFeedback with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +ActiveLearningFeedback body = new ActiveLearningFeedback +{ + Records = {new FeedbackRecord + { + UserId = "", + UserQuestion = "", + QnaId = 1234, + }}, +}; +Response response = client.AddFeedback("", body); ]]> @@ -795,7 +1203,7 @@ This sample shows how to call AddFeedbackAsync. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object()); Response response = await client.AddFeedbackAsync("", content); @@ -806,7 +1214,7 @@ This sample shows how to call AddFeedbackAsync with all parameters and request c "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new { @@ -831,7 +1239,7 @@ This sample shows how to call AddFeedback. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object()); Response response = client.AddFeedback("", content); @@ -842,7 +1250,7 @@ This sample shows how to call AddFeedback with all parameters and request conten "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new { @@ -861,27 +1269,73 @@ Response response = client.AddFeedback("", content); Console.WriteLine(response.Status); ]]> - + + +This sample shows how to call GetProjectsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +await foreach (ProjectMetadata item in client.GetProjectsAsync()) +{ +} +]]> +This sample shows how to call GetProjectsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +await foreach (ProjectMetadata item in client.GetProjectsAsync(maxCount: 1234, skip: 1234, maxpagesize: 1234)) +{ +} +]]> + + + +This sample shows how to call GetProjects. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +foreach (ProjectMetadata item in client.GetProjects()) +{ +} +]]> +This sample shows how to call GetProjects with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +foreach (ProjectMetadata item in client.GetProjects(maxCount: 1234, skip: 1234, maxpagesize: 1234)) +{ +} +]]> + + This sample shows how to call GetProjectsAsync and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -await foreach (BinaryData item in client.GetProjectsAsync()) +await foreach (BinaryData item in client.GetProjectsAsync(null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("projectName").ToString()); } ]]> -This sample shows how to call GetProjectsAsync with all request content and parse the result. +This sample shows how to call GetProjectsAsync with all parameters and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -await foreach (BinaryData item in client.GetProjectsAsync()) +await foreach (BinaryData item in client.GetProjectsAsync(1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; Console.WriteLine(result.GetProperty("projectName").ToString()); @@ -895,27 +1349,27 @@ await foreach (BinaryData item in client.GetProjectsAsync()) } ]]> - + This sample shows how to call GetProjects and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -foreach (BinaryData item in client.GetProjects()) +foreach (BinaryData item in client.GetProjects(null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("projectName").ToString()); } ]]> -This sample shows how to call GetProjects with all request content and parse the result. +This sample shows how to call GetProjects with all parameters and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -foreach (BinaryData item in client.GetProjects()) +foreach (BinaryData item in client.GetProjects(1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; Console.WriteLine(result.GetProperty("projectName").ToString()); @@ -929,27 +1383,73 @@ foreach (BinaryData item in client.GetProjects()) } ]]> - + + +This sample shows how to call GetDeploymentsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +await foreach (ProjectDeployment item in client.GetDeploymentsAsync("")) +{ +} +]]> +This sample shows how to call GetDeploymentsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +await foreach (ProjectDeployment item in client.GetDeploymentsAsync("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) +{ +} +]]> + + + +This sample shows how to call GetDeployments. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +foreach (ProjectDeployment item in client.GetDeployments("")) +{ +} +]]> +This sample shows how to call GetDeployments with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +foreach (ProjectDeployment item in client.GetDeployments("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) +{ +} +]]> + + This sample shows how to call GetDeploymentsAsync and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -await foreach (BinaryData item in client.GetDeploymentsAsync("")) +await foreach (BinaryData item in client.GetDeploymentsAsync("", null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("deploymentName").ToString()); } ]]> This sample shows how to call GetDeploymentsAsync with all parameters and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -await foreach (BinaryData item in client.GetDeploymentsAsync("")) +await foreach (BinaryData item in client.GetDeploymentsAsync("", 1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; Console.WriteLine(result.GetProperty("deploymentName").ToString()); @@ -957,27 +1457,27 @@ await foreach (BinaryData item in client.GetDeploymentsAsync("")) } ]]> - + This sample shows how to call GetDeployments and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -foreach (BinaryData item in client.GetDeployments("")) +foreach (BinaryData item in client.GetDeployments("", null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("deploymentName").ToString()); } ]]> This sample shows how to call GetDeployments with all parameters and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -foreach (BinaryData item in client.GetDeployments("")) +foreach (BinaryData item in client.GetDeployments("", 1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; Console.WriteLine(result.GetProperty("deploymentName").ToString()); @@ -985,15 +1485,61 @@ foreach (BinaryData item in client.GetDeployments("")) } ]]> - + + +This sample shows how to call GetSynonymsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +await foreach (WordAlterations item in client.GetSynonymsAsync("")) +{ +} +]]> +This sample shows how to call GetSynonymsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +await foreach (WordAlterations item in client.GetSynonymsAsync("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) +{ +} +]]> + + + +This sample shows how to call GetSynonyms. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +foreach (WordAlterations item in client.GetSynonyms("")) +{ +} +]]> +This sample shows how to call GetSynonyms with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +foreach (WordAlterations item in client.GetSynonyms("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) +{ +} +]]> + + This sample shows how to call GetSynonymsAsync and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -await foreach (BinaryData item in client.GetSynonymsAsync("")) +await foreach (BinaryData item in client.GetSynonymsAsync("", null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; Console.WriteLine(result.GetProperty("alterations")[0].ToString()); @@ -1003,24 +1549,24 @@ This sample shows how to call GetSynonymsAsync with all parameters and parse the "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -await foreach (BinaryData item in client.GetSynonymsAsync("")) +await foreach (BinaryData item in client.GetSynonymsAsync("", 1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; Console.WriteLine(result.GetProperty("alterations")[0].ToString()); } ]]> - + This sample shows how to call GetSynonyms and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -foreach (BinaryData item in client.GetSynonyms("")) +foreach (BinaryData item in client.GetSynonyms("", null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; Console.WriteLine(result.GetProperty("alterations")[0].ToString()); @@ -1030,26 +1576,73 @@ This sample shows how to call GetSynonyms with all parameters and parse the resu "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -foreach (BinaryData item in client.GetSynonyms("")) +foreach (BinaryData item in client.GetSynonyms("", 1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; Console.WriteLine(result.GetProperty("alterations")[0].ToString()); } ]]> - + + +This sample shows how to call GetSourcesAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +await foreach (QnaSourceRecord item in client.GetSourcesAsync("")) +{ +} +]]> +This sample shows how to call GetSourcesAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +await foreach (QnaSourceRecord item in client.GetSourcesAsync("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) +{ +} +]]> + + + +This sample shows how to call GetSources. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +foreach (QnaSourceRecord item in client.GetSources("")) +{ +} +]]> +This sample shows how to call GetSources with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +foreach (QnaSourceRecord item in client.GetSources("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) +{ +} +]]> + + This sample shows how to call GetSourcesAsync and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -await foreach (BinaryData item in client.GetSourcesAsync("")) +await foreach (BinaryData item in client.GetSourcesAsync("", null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("source").ToString()); Console.WriteLine(result.GetProperty("sourceUri").ToString()); Console.WriteLine(result.GetProperty("sourceKind").ToString()); } @@ -1058,31 +1651,32 @@ This sample shows how to call GetSourcesAsync with all parameters and parse the "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -await foreach (BinaryData item in client.GetSourcesAsync("")) +await foreach (BinaryData item in client.GetSourcesAsync("", 1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); Console.WriteLine(result.GetProperty("displayName").ToString()); Console.WriteLine(result.GetProperty("source").ToString()); Console.WriteLine(result.GetProperty("sourceUri").ToString()); Console.WriteLine(result.GetProperty("sourceKind").ToString()); Console.WriteLine(result.GetProperty("contentStructureKind").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); } ]]> - + This sample shows how to call GetSources and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -foreach (BinaryData item in client.GetSources("")) +foreach (BinaryData item in client.GetSources("", null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("source").ToString()); Console.WriteLine(result.GetProperty("sourceUri").ToString()); Console.WriteLine(result.GetProperty("sourceKind").ToString()); } @@ -1091,44 +1685,89 @@ This sample shows how to call GetSources with all parameters and parse the resul "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -foreach (BinaryData item in client.GetSources("")) +foreach (BinaryData item in client.GetSources("", 1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); Console.WriteLine(result.GetProperty("displayName").ToString()); Console.WriteLine(result.GetProperty("source").ToString()); Console.WriteLine(result.GetProperty("sourceUri").ToString()); Console.WriteLine(result.GetProperty("sourceKind").ToString()); Console.WriteLine(result.GetProperty("contentStructureKind").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); +} +]]> + + + +This sample shows how to call GetQnasAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +await foreach (RetrieveQnaRecord item in client.GetQnasAsync("")) +{ +} +]]> +This sample shows how to call GetQnasAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +await foreach (RetrieveQnaRecord item in client.GetQnasAsync("", maxCount: 1234, skip: 1234, maxpagesize: 1234, source: "")) +{ } ]]> - + + +This sample shows how to call GetQnas. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +foreach (RetrieveQnaRecord item in client.GetQnas("")) +{ +} +]]> +This sample shows how to call GetQnas with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +foreach (RetrieveQnaRecord item in client.GetQnas("", maxCount: 1234, skip: 1234, maxpagesize: 1234, source: "")) +{ +} +]]> + + This sample shows how to call GetQnasAsync and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -await foreach (BinaryData item in client.GetQnasAsync("")) +await foreach (BinaryData item in client.GetQnasAsync("", null, null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); } ]]> This sample shows how to call GetQnasAsync with all parameters and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -await foreach (BinaryData item in client.GetQnasAsync("", source: "")) +await foreach (BinaryData item in client.GetQnasAsync("", 1234, 1234, 1234, "", null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); Console.WriteLine(result.GetProperty("id").ToString()); Console.WriteLine(result.GetProperty("answer").ToString()); Console.WriteLine(result.GetProperty("source").ToString()); @@ -1151,33 +1790,33 @@ await foreach (BinaryData item in client.GetQnasAsync("", source: " Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("question").ToString()); Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("userSuggestedCount").ToString()); Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("autoSuggestedCount").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); } ]]> - + This sample shows how to call GetQnas and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -foreach (BinaryData item in client.GetQnas("")) +foreach (BinaryData item in client.GetQnas("", null, null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); } ]]> This sample shows how to call GetQnas with all parameters and parse the result. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -foreach (BinaryData item in client.GetQnas("", source: "")) +foreach (BinaryData item in client.GetQnas("", 1234, 1234, 1234, "", null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); Console.WriteLine(result.GetProperty("id").ToString()); Console.WriteLine(result.GetProperty("answer").ToString()); Console.WriteLine(result.GetProperty("source").ToString()); @@ -1200,6 +1839,7 @@ foreach (BinaryData item in client.GetQnas("", source: "")) Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("question").ToString()); Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("userSuggestedCount").ToString()); Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("autoSuggestedCount").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); } ]]> @@ -1209,161 +1849,290 @@ This sample shows how to call DeleteProjectAsync. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); Operation operation = await client.DeleteProjectAsync(WaitUntil.Completed, ""); ]]> -This sample shows how to call DeleteProjectAsync with all parameters. +This sample shows how to call DeleteProjectAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Operation operation = await client.DeleteProjectAsync(WaitUntil.Completed, ""); +]]> + + + +This sample shows how to call DeleteProject. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Operation operation = client.DeleteProject(WaitUntil.Completed, ""); +]]> +This sample shows how to call DeleteProject with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Operation operation = client.DeleteProject(WaitUntil.Completed, ""); +]]> + + + +This sample shows how to call ExportAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Operation operation = await client.ExportAsync(WaitUntil.Completed, ""); +]]> +This sample shows how to call ExportAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Operation operation = await client.ExportAsync(WaitUntil.Completed, "", format: ImportExportFormat.Json, assetKind: AssestKind.Qnas); +]]> + + + +This sample shows how to call Export. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Operation operation = client.Export(WaitUntil.Completed, ""); +]]> +This sample shows how to call Export with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Operation operation = client.Export(WaitUntil.Completed, "", format: ImportExportFormat.Json, assetKind: AssestKind.Qnas); +]]> + + + +This sample shows how to call ExportAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + +Operation operation = await client.ExportAsync(WaitUntil.Completed, "", null, null, null); +]]> +This sample shows how to call ExportAsync with all parameters. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Operation operation = await client.DeleteProjectAsync(WaitUntil.Completed, ""); +Operation operation = await client.ExportAsync(WaitUntil.Completed, "", "json", "qnas", null); ]]> - + -This sample shows how to call DeleteProject. +This sample shows how to call Export. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Operation operation = client.DeleteProject(WaitUntil.Completed, ""); +Operation operation = client.Export(WaitUntil.Completed, "", null, null, null); ]]> -This sample shows how to call DeleteProject with all parameters. +This sample shows how to call Export with all parameters. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Operation operation = client.DeleteProject(WaitUntil.Completed, ""); +Operation operation = client.Export(WaitUntil.Completed, "", "json", "qnas", null); ]]> - + -This sample shows how to call ExportAsync and parse the result. +This sample shows how to call ImportAsync. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); - -Operation operation = await client.ExportAsync(WaitUntil.Completed, ""); -BinaryData responseData = operation.Value; +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; -Console.WriteLine(result.GetProperty("resultUrl").ToString()); -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); +Operation operation = await client.ImportAsync(WaitUntil.Completed, ""); ]]> -This sample shows how to call ExportAsync with all parameters and parse the result. +This sample shows how to call ImportAsync with all parameters. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); - -Operation operation = await client.ExportAsync(WaitUntil.Completed, "", format: "json", assetKind: "qnas"); -BinaryData responseData = operation.Value; +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; -Console.WriteLine(result.GetProperty("resultUrl").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("code").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("message").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("code").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("message").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("code").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); +ImportJobOptions body = new ImportJobOptions +{ + Metadata = new CreateProjectOptions("") + { + Description = "", + MultilingualResource = true, + Settings = new ProjectSettings + { + DefaultAnswer = "", + }, + }, + Assets = new Assets + { + Synonyms = { new WordAlterations(new string[] { "" }) }, + Qnas = {new ImportQnaRecord + { + Answer = "", + Source = "", + Questions = {""}, + Metadata = + { + ["key"] = "" + }, + Dialog = new QnaDialog + { + IsContextOnly = true, + Prompts = {new QnaPrompt + { + DisplayOrder = 1234, + QnaId = 1234, + Qna = new QnaRecord + { + Answer = "", + Source = "", + Questions = {""}, + Metadata = + { + ["key"] = "" + }, + Dialog = default, + ActiveLearningSuggestions = {new SuggestedQuestionsCluster + { + ClusterHead = "", + SuggestedQuestions = {new SuggestedQuestion + { + Question = "", + UserSuggestedCount = 1234, + AutoSuggestedCount = 1234, + }}, + }}, + }, + DisplayText = "", + }}, + }, + ActiveLearningSuggestions = {default}, + LastUpdatedDateTime = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), + SourceDisplayName = "", + }}, + }, + FileUri = "", +}; +Operation operation = await client.ImportAsync(WaitUntil.Completed, "", body: body, format: ImportExportFormat.Json, assetKind: AssestKind.Qnas); ]]> - + -This sample shows how to call Export and parse the result. +This sample shows how to call Import. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); - -Operation operation = client.Export(WaitUntil.Completed, ""); -BinaryData responseData = operation.Value; +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; -Console.WriteLine(result.GetProperty("resultUrl").ToString()); -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); +Operation operation = client.Import(WaitUntil.Completed, ""); ]]> -This sample shows how to call Export with all parameters and parse the result. +This sample shows how to call Import with all parameters. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); - -Operation operation = client.Export(WaitUntil.Completed, "", format: "json", assetKind: "qnas"); -BinaryData responseData = operation.Value; +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; -Console.WriteLine(result.GetProperty("resultUrl").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("code").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("message").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("code").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("message").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("code").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); +ImportJobOptions body = new ImportJobOptions +{ + Metadata = new CreateProjectOptions("") + { + Description = "", + MultilingualResource = true, + Settings = new ProjectSettings + { + DefaultAnswer = "", + }, + }, + Assets = new Assets + { + Synonyms = { new WordAlterations(new string[] { "" }) }, + Qnas = {new ImportQnaRecord + { + Answer = "", + Source = "", + Questions = {""}, + Metadata = + { + ["key"] = "" + }, + Dialog = new QnaDialog + { + IsContextOnly = true, + Prompts = {new QnaPrompt + { + DisplayOrder = 1234, + QnaId = 1234, + Qna = new QnaRecord + { + Answer = "", + Source = "", + Questions = {""}, + Metadata = + { + ["key"] = "" + }, + Dialog = default, + ActiveLearningSuggestions = {new SuggestedQuestionsCluster + { + ClusterHead = "", + SuggestedQuestions = {new SuggestedQuestion + { + Question = "", + UserSuggestedCount = 1234, + AutoSuggestedCount = 1234, + }}, + }}, + }, + DisplayText = "", + }}, + }, + ActiveLearningSuggestions = {default}, + LastUpdatedDateTime = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), + SourceDisplayName = "", + }}, + }, + FileUri = "", +}; +Operation operation = client.Import(WaitUntil.Completed, "", body: body, format: ImportExportFormat.Json, assetKind: AssestKind.Qnas); ]]> -This sample shows how to call ImportAsync and parse the result. +This sample shows how to call ImportAsync. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = null; -Operation operation = await client.ImportAsync(WaitUntil.Completed, "", content); -BinaryData responseData = operation.Value; - -JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); +Operation operation = await client.ImportAsync(WaitUntil.Completed, "", content); ]]> -This sample shows how to call ImportAsync with all parameters and request content and parse the result. +This sample shows how to call ImportAsync with all parameters and request content. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new { @@ -1393,9 +2162,6 @@ using RequestContent content = RequestContent.Create(new { new { - sourceDisplayName = "", - lastUpdatedDateTime = "2022-05-10T18:57:31.2311892Z", - id = 1234, answer = "", source = "", questions = new object[] @@ -1417,7 +2183,6 @@ using RequestContent content = RequestContent.Create(new qnaId = 1234, qna = new { - id = 1234, answer = "", source = "", questions = new object[] @@ -1453,59 +2218,32 @@ using RequestContent content = RequestContent.Create(new { null }, + lastUpdatedDateTime = "2022-05-10T18:57:31.2311892Z", + sourceDisplayName = "", } }, }, fileUri = "", }); -Operation operation = await client.ImportAsync(WaitUntil.Completed, "", content, format: "json", assetKind: "qnas"); -BinaryData responseData = operation.Value; - -JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("code").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("message").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("code").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("message").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("code").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); +Operation operation = await client.ImportAsync(WaitUntil.Completed, "", content, format: "json", assetKind: "qnas"); ]]> -This sample shows how to call Import and parse the result. +This sample shows how to call Import. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = null; -Operation operation = client.Import(WaitUntil.Completed, "", content); -BinaryData responseData = operation.Value; - -JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); +Operation operation = client.Import(WaitUntil.Completed, "", content); ]]> -This sample shows how to call Import with all parameters and request content and parse the result. +This sample shows how to call Import with all parameters and request content. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new { @@ -1535,9 +2273,6 @@ using RequestContent content = RequestContent.Create(new { new { - sourceDisplayName = "", - lastUpdatedDateTime = "2022-05-10T18:57:31.2311892Z", - id = 1234, answer = "", source = "", questions = new object[] @@ -1559,7 +2294,6 @@ using RequestContent content = RequestContent.Create(new qnaId = 1234, qna = new { - id = 1234, answer = "", source = "", questions = new object[] @@ -1595,99 +2329,61 @@ using RequestContent content = RequestContent.Create(new { null }, + lastUpdatedDateTime = "2022-05-10T18:57:31.2311892Z", + sourceDisplayName = "", } }, }, fileUri = "", }); -Operation operation = client.Import(WaitUntil.Completed, "", content, format: "json", assetKind: "qnas"); -BinaryData responseData = operation.Value; - -JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("code").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("message").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("code").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("message").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("code").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); -Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); -Console.WriteLine(result.GetProperty("createdDateTime").ToString()); -Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); -Console.WriteLine(result.GetProperty("jobId").ToString()); -Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); -Console.WriteLine(result.GetProperty("status").ToString()); +Operation operation = client.Import(WaitUntil.Completed, "", content, format: "json", assetKind: "qnas"); ]]> -This sample shows how to call DeployProjectAsync and parse the result. +This sample shows how to call DeployProjectAsync. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Operation operation = await client.DeployProjectAsync(WaitUntil.Completed, "", ""); -BinaryData responseData = operation.Value; - -JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; -Console.WriteLine(result.ToString()); +Operation operation = await client.DeployProjectAsync(WaitUntil.Completed, "", ""); ]]> -This sample shows how to call DeployProjectAsync with all parameters and parse the result. +This sample shows how to call DeployProjectAsync with all parameters. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); - -Operation operation = await client.DeployProjectAsync(WaitUntil.Completed, "", ""); -BinaryData responseData = operation.Value; +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; -Console.WriteLine(result.GetProperty("deploymentName").ToString()); -Console.WriteLine(result.GetProperty("lastDeployedDateTime").ToString()); +Operation operation = await client.DeployProjectAsync(WaitUntil.Completed, "", ""); ]]> -This sample shows how to call DeployProject and parse the result. +This sample shows how to call DeployProject. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); - -Operation operation = client.DeployProject(WaitUntil.Completed, "", ""); -BinaryData responseData = operation.Value; +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; -Console.WriteLine(result.ToString()); +Operation operation = client.DeployProject(WaitUntil.Completed, "", ""); ]]> -This sample shows how to call DeployProject with all parameters and parse the result. +This sample shows how to call DeployProject with all parameters. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); -Operation operation = client.DeployProject(WaitUntil.Completed, "", ""); -BinaryData responseData = operation.Value; - -JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; -Console.WriteLine(result.GetProperty("deploymentName").ToString()); -Console.WriteLine(result.GetProperty("lastDeployedDateTime").ToString()); +Operation operation = client.DeployProject(WaitUntil.Completed, "", ""); ]]> -This sample shows how to call UpdateSourcesAsync and parse the result. +This sample shows how to call UpdateSourcesAsync. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object[] { @@ -1696,25 +2392,19 @@ using RequestContent content = RequestContent.Create(new object[] op = "add", value = new { + source = "", sourceUri = "http://localhost:3000", sourceKind = "file", }, } }); -Operation> operation = await client.UpdateSourcesAsync(WaitUntil.Completed, "", content); -AsyncPageable responseData = operation.Value; -await foreach (BinaryData item in operation.Value) -{ - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("sourceUri").ToString()); - Console.WriteLine(result.GetProperty("sourceKind").ToString()); -} +Operation operation = await client.UpdateSourcesAsync(WaitUntil.Completed, "", content); ]]> -This sample shows how to call UpdateSourcesAsync with all parameters and request content and parse the result. +This sample shows how to call UpdateSourcesAsync with all parameters and request content. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object[] { @@ -1723,36 +2413,25 @@ using RequestContent content = RequestContent.Create(new object[] op = "add", value = new { - refresh = true, displayName = "", source = "", sourceUri = "http://localhost:3000", sourceKind = "file", contentStructureKind = "unstructured", + refresh = true, }, } }); -Operation> operation = await client.UpdateSourcesAsync(WaitUntil.Completed, "", content); -AsyncPageable responseData = operation.Value; -await foreach (BinaryData item in operation.Value) -{ - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("displayName").ToString()); - Console.WriteLine(result.GetProperty("source").ToString()); - Console.WriteLine(result.GetProperty("sourceUri").ToString()); - Console.WriteLine(result.GetProperty("sourceKind").ToString()); - Console.WriteLine(result.GetProperty("contentStructureKind").ToString()); -} +Operation operation = await client.UpdateSourcesAsync(WaitUntil.Completed, "", content); ]]> -This sample shows how to call UpdateSources and parse the result. +This sample shows how to call UpdateSources. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object[] { @@ -1761,25 +2440,19 @@ using RequestContent content = RequestContent.Create(new object[] op = "add", value = new { + source = "", sourceUri = "http://localhost:3000", sourceKind = "file", }, } }); -Operation> operation = client.UpdateSources(WaitUntil.Completed, "", content); -Pageable responseData = operation.Value; -foreach (BinaryData item in operation.Value) -{ - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("sourceUri").ToString()); - Console.WriteLine(result.GetProperty("sourceKind").ToString()); -} +Operation operation = client.UpdateSources(WaitUntil.Completed, "", content); ]]> -This sample shows how to call UpdateSources with all parameters and request content and parse the result. +This sample shows how to call UpdateSources with all parameters and request content. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object[] { @@ -1788,36 +2461,25 @@ using RequestContent content = RequestContent.Create(new object[] op = "add", value = new { - refresh = true, displayName = "", source = "", sourceUri = "http://localhost:3000", sourceKind = "file", contentStructureKind = "unstructured", + refresh = true, }, } }); -Operation> operation = client.UpdateSources(WaitUntil.Completed, "", content); -Pageable responseData = operation.Value; -foreach (BinaryData item in operation.Value) -{ - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("displayName").ToString()); - Console.WriteLine(result.GetProperty("source").ToString()); - Console.WriteLine(result.GetProperty("sourceUri").ToString()); - Console.WriteLine(result.GetProperty("sourceKind").ToString()); - Console.WriteLine(result.GetProperty("contentStructureKind").ToString()); -} +Operation operation = client.UpdateSources(WaitUntil.Completed, "", content); ]]> -This sample shows how to call UpdateQnasAsync and parse the result. +This sample shows how to call UpdateQnasAsync. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object[] { @@ -1827,19 +2489,13 @@ using RequestContent content = RequestContent.Create(new object[] value = new object(), } }); -Operation> operation = await client.UpdateQnasAsync(WaitUntil.Completed, "", content); -AsyncPageable responseData = operation.Value; -await foreach (BinaryData item in operation.Value) -{ - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.ToString()); -} +Operation operation = await client.UpdateQnasAsync(WaitUntil.Completed, "", content); ]]> -This sample shows how to call UpdateQnasAsync with all parameters and request content and parse the result. +This sample shows how to call UpdateQnasAsync with all parameters and request content. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object[] { @@ -1848,7 +2504,6 @@ using RequestContent content = RequestContent.Create(new object[] op = "add", value = new { - id = 1234, answer = "", source = "", questions = new object[] @@ -1891,44 +2546,16 @@ using RequestContent content = RequestContent.Create(new object[] }, } }); -Operation> operation = await client.UpdateQnasAsync(WaitUntil.Completed, "", content); -AsyncPageable responseData = operation.Value; -await foreach (BinaryData item in operation.Value) -{ - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("id").ToString()); - Console.WriteLine(result.GetProperty("answer").ToString()); - Console.WriteLine(result.GetProperty("source").ToString()); - Console.WriteLine(result.GetProperty("questions")[0].ToString()); - Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("isContextOnly").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("displayOrder").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qnaId").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("id").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("answer").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("source").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("questions")[0].ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("metadata").GetProperty("").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("activeLearningSuggestions")[0].GetProperty("clusterHead").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("question").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("userSuggestedCount").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("autoSuggestedCount").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("displayText").ToString()); - Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("clusterHead").ToString()); - Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("question").ToString()); - Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("userSuggestedCount").ToString()); - Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("autoSuggestedCount").ToString()); -} +Operation operation = await client.UpdateQnasAsync(WaitUntil.Completed, "", content); ]]> -This sample shows how to call UpdateQnas and parse the result. +This sample shows how to call UpdateQnas. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object[] { @@ -1938,19 +2565,13 @@ using RequestContent content = RequestContent.Create(new object[] value = new object(), } }); -Operation> operation = client.UpdateQnas(WaitUntil.Completed, "", content); -Pageable responseData = operation.Value; -foreach (BinaryData item in operation.Value) -{ - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.ToString()); -} +Operation operation = client.UpdateQnas(WaitUntil.Completed, "", content); ]]> -This sample shows how to call UpdateQnas with all parameters and request content and parse the result. +This sample shows how to call UpdateQnas with all parameters and request content. "); AzureKeyCredential credential = new AzureKeyCredential(""); -QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); +QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object[] { @@ -1959,7 +2580,6 @@ using RequestContent content = RequestContent.Create(new object[] op = "add", value = new { - id = 1234, answer = "", source = "", questions = new object[] @@ -2002,35 +2622,7 @@ using RequestContent content = RequestContent.Create(new object[] }, } }); -Operation> operation = client.UpdateQnas(WaitUntil.Completed, "", content); -Pageable responseData = operation.Value; -foreach (BinaryData item in operation.Value) -{ - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("id").ToString()); - Console.WriteLine(result.GetProperty("answer").ToString()); - Console.WriteLine(result.GetProperty("source").ToString()); - Console.WriteLine(result.GetProperty("questions")[0].ToString()); - Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("isContextOnly").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("displayOrder").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qnaId").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("id").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("answer").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("source").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("questions")[0].ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("metadata").GetProperty("").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("activeLearningSuggestions")[0].GetProperty("clusterHead").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("question").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("userSuggestedCount").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("autoSuggestedCount").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("displayText").ToString()); - Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("clusterHead").ToString()); - Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("question").ToString()); - Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("userSuggestedCount").ToString()); - Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("autoSuggestedCount").ToString()); -} +Operation operation = client.UpdateQnas(WaitUntil.Completed, "", content); ]]> diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Error.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Error.Serialization.cs new file mode 100644 index 000000000000..c9dd3b3b1102 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Error.Serialization.cs @@ -0,0 +1,207 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class Error : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Error)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code.ToString()); + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + if (Optional.IsDefined(Target)) + { + writer.WritePropertyName("target"u8); + writer.WriteStringValue(Target); + } + if (Optional.IsCollectionDefined(Details)) + { + writer.WritePropertyName("details"u8); + writer.WriteStartArray(); + foreach (var item in Details) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Innererror)) + { + writer.WritePropertyName("innererror"u8); + writer.WriteObjectValue(Innererror, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Error IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Error)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeError(document.RootElement, options); + } + + internal static Error DeserializeError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ErrorCode code = default; + string message = default; + string target = default; + IReadOnlyList details = default; + InnerErrorModel innererror = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code"u8)) + { + code = new ErrorCode(property.Value.GetString()); + continue; + } + if (property.NameEquals("message"u8)) + { + message = property.Value.GetString(); + continue; + } + if (property.NameEquals("target"u8)) + { + target = property.Value.GetString(); + continue; + } + if (property.NameEquals("details"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DeserializeError(item, options)); + } + details = array; + continue; + } + if (property.NameEquals("innererror"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + innererror = InnerErrorModel.DeserializeInnerErrorModel(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Error( + code, + message, + target, + details ?? new ChangeTrackingList(), + innererror, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Error)} does not support writing '{options.Format}' format."); + } + } + + Error IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Error)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static Error FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeError(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Error.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Error.cs new file mode 100644 index 000000000000..2d6be6506aef --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Error.cs @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// The error object. + public partial class Error + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// One of a server-defined set of error codes. + /// A human-readable representation of the error. + /// is null. + internal Error(ErrorCode code, string message) + { + Argument.AssertNotNull(message, nameof(message)); + + Code = code; + Message = message; + Details = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// One of a server-defined set of error codes. + /// A human-readable representation of the error. + /// The target of the error. + /// An array of details about specific errors that led to this reported error. + /// + /// An object containing more specific information than the current object about + /// the error. + /// + /// Keeps track of any properties unknown to the library. + internal Error(ErrorCode code, string message, string target, IReadOnlyList details, InnerErrorModel innererror, IDictionary serializedAdditionalRawData) + { + Code = code; + Message = message; + Target = target; + Details = details; + Innererror = innererror; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Error() + { + } + + /// One of a server-defined set of error codes. + public ErrorCode Code { get; } + /// A human-readable representation of the error. + public string Message { get; } + /// The target of the error. + public string Target { get; } + /// An array of details about specific errors that led to this reported error. + public IReadOnlyList Details { get; } + /// + /// An object containing more specific information than the current object about + /// the error. + /// + public InnerErrorModel Innererror { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/ErrorCode.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ErrorCode.cs similarity index 71% rename from sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/ErrorCode.cs rename to sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ErrorCode.cs index 60c5c9dee9c9..229533dfd1d0 100644 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/ErrorCode.cs +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ErrorCode.cs @@ -8,10 +8,10 @@ using System; using System.ComponentModel; -namespace Azure.AI.Language.QuestionAnswering +namespace Azure.AI.Language.QuestionAnswering.Authoring { /// Human-readable error code. - internal readonly partial struct ErrorCode : IEquatable + public readonly partial struct ErrorCode : IEquatable { private readonly string _value; @@ -36,35 +36,47 @@ public ErrorCode(string value) private const string AzureCognitiveSearchIndexLimitReachedValue = "AzureCognitiveSearchIndexLimitReached"; private const string InternalServerErrorValue = "InternalServerError"; private const string ServiceUnavailableValue = "ServiceUnavailable"; + private const string TimeoutValue = "Timeout"; + private const string QuotaExceededValue = "QuotaExceeded"; + private const string ConflictValue = "Conflict"; + private const string WarningValue = "Warning"; - /// InvalidRequest. + /// Invalid request error. public static ErrorCode InvalidRequest { get; } = new ErrorCode(InvalidRequestValue); - /// InvalidArgument. + /// Invalid argument error. public static ErrorCode InvalidArgument { get; } = new ErrorCode(InvalidArgumentValue); - /// Unauthorized. + /// Unauthorized access error. public static ErrorCode Unauthorized { get; } = new ErrorCode(UnauthorizedValue); - /// Forbidden. + /// Forbidden access error. public static ErrorCode Forbidden { get; } = new ErrorCode(ForbiddenValue); - /// NotFound. + /// Not found error. public static ErrorCode NotFound { get; } = new ErrorCode(NotFoundValue); - /// ProjectNotFound. + /// Project not found error. public static ErrorCode ProjectNotFound { get; } = new ErrorCode(ProjectNotFoundValue); - /// OperationNotFound. + /// Operation not found error. public static ErrorCode OperationNotFound { get; } = new ErrorCode(OperationNotFoundValue); - /// AzureCognitiveSearchNotFound. + /// Azure Cognitive Search not found error. public static ErrorCode AzureCognitiveSearchNotFound { get; } = new ErrorCode(AzureCognitiveSearchNotFoundValue); - /// AzureCognitiveSearchIndexNotFound. + /// Azure Cognitive Search index not found error. public static ErrorCode AzureCognitiveSearchIndexNotFound { get; } = new ErrorCode(AzureCognitiveSearchIndexNotFoundValue); - /// TooManyRequests. + /// Too many requests error. public static ErrorCode TooManyRequests { get; } = new ErrorCode(TooManyRequestsValue); - /// AzureCognitiveSearchThrottling. + /// Azure Cognitive Search throttling error. public static ErrorCode AzureCognitiveSearchThrottling { get; } = new ErrorCode(AzureCognitiveSearchThrottlingValue); - /// AzureCognitiveSearchIndexLimitReached. + /// Azure Cognitive Search index limit reached error. public static ErrorCode AzureCognitiveSearchIndexLimitReached { get; } = new ErrorCode(AzureCognitiveSearchIndexLimitReachedValue); - /// InternalServerError. + /// Internal server error. public static ErrorCode InternalServerError { get; } = new ErrorCode(InternalServerErrorValue); - /// ServiceUnavailable. + /// Service unavailable error. public static ErrorCode ServiceUnavailable { get; } = new ErrorCode(ServiceUnavailableValue); + /// Timeout error. + public static ErrorCode Timeout { get; } = new ErrorCode(TimeoutValue); + /// Quota exceeded error. + public static ErrorCode QuotaExceeded { get; } = new ErrorCode(QuotaExceededValue); + /// Conflict error. + public static ErrorCode Conflict { get; } = new ErrorCode(ConflictValue); + /// Warning error. + public static ErrorCode Warning { get; } = new ErrorCode(WarningValue); /// Determines if two values are the same. public static bool operator ==(ErrorCode left, ErrorCode right) => left.Equals(right); /// Determines if two values are not the same. diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/FeedbackRecord.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/FeedbackRecord.Serialization.cs new file mode 100644 index 000000000000..d903851d9b37 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/FeedbackRecord.Serialization.cs @@ -0,0 +1,171 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class FeedbackRecord : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FeedbackRecord)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(UserId)) + { + writer.WritePropertyName("userId"u8); + writer.WriteStringValue(UserId); + } + if (Optional.IsDefined(UserQuestion)) + { + writer.WritePropertyName("userQuestion"u8); + writer.WriteStringValue(UserQuestion); + } + if (Optional.IsDefined(QnaId)) + { + writer.WritePropertyName("qnaId"u8); + writer.WriteNumberValue(QnaId.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + FeedbackRecord IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FeedbackRecord)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFeedbackRecord(document.RootElement, options); + } + + internal static FeedbackRecord DeserializeFeedbackRecord(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string userId = default; + string userQuestion = default; + int? qnaId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("userId"u8)) + { + userId = property.Value.GetString(); + continue; + } + if (property.NameEquals("userQuestion"u8)) + { + userQuestion = property.Value.GetString(); + continue; + } + if (property.NameEquals("qnaId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + qnaId = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FeedbackRecord(userId, userQuestion, qnaId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FeedbackRecord)} does not support writing '{options.Format}' format."); + } + } + + FeedbackRecord IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFeedbackRecord(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FeedbackRecord)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static FeedbackRecord FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFeedbackRecord(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/FeedbackRecord.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/FeedbackRecord.cs new file mode 100644 index 000000000000..93d657602ff8 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/FeedbackRecord.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Feedback Record for Active Learning. + public partial class FeedbackRecord + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public FeedbackRecord() + { + } + + /// Initializes a new instance of . + /// Unique identifier of the user. + /// User suggested question for the QnA. + /// Unique ID of the QnA. + /// Keeps track of any properties unknown to the library. + internal FeedbackRecord(string userId, string userQuestion, int? qnaId, IDictionary serializedAdditionalRawData) + { + UserId = userId; + UserQuestion = userQuestion; + QnaId = qnaId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Unique identifier of the user. + public string UserId { get; set; } + /// User suggested question for the QnA. + public string UserQuestion { get; set; } + /// Unique ID of the QnA. + public int? QnaId { get; set; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ImportExportFormat.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ImportExportFormat.cs new file mode 100644 index 000000000000..15f73169bab3 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ImportExportFormat.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Knowledge base Import or Export format. + public readonly partial struct ImportExportFormat : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ImportExportFormat(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string JsonValue = "json"; + private const string TsvValue = "tsv"; + private const string ExcelValue = "excel"; + + /// Export or Import QnA assets in JSON format. + public static ImportExportFormat Json { get; } = new ImportExportFormat(JsonValue); + /// + /// Export or Import knowledge base replica including all assets and metadata in + /// Excel format. + /// + public static ImportExportFormat Tsv { get; } = new ImportExportFormat(TsvValue); + /// + /// Export or Import knowledge base replica including all assets and metadata in + /// Tsv format. + /// + public static ImportExportFormat Excel { get; } = new ImportExportFormat(ExcelValue); + /// Determines if two values are the same. + public static bool operator ==(ImportExportFormat left, ImportExportFormat right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ImportExportFormat left, ImportExportFormat right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ImportExportFormat(string value) => new ImportExportFormat(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImportExportFormat other && Equals(other); + /// + public bool Equals(ImportExportFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ImportJobOptions.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ImportJobOptions.Serialization.cs new file mode 100644 index 000000000000..4be299141745 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ImportJobOptions.Serialization.cs @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class ImportJobOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ImportJobOptions)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteObjectValue(Metadata, options); + } + if (Optional.IsDefined(Assets)) + { + writer.WritePropertyName("assets"u8); + writer.WriteObjectValue(Assets, options); + } + if (Optional.IsDefined(FileUri)) + { + writer.WritePropertyName("fileUri"u8); + writer.WriteStringValue(FileUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ImportJobOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ImportJobOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeImportJobOptions(document.RootElement, options); + } + + internal static ImportJobOptions DeserializeImportJobOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CreateProjectOptions metadata = default; + Assets assets = default; + string fileUri = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + metadata = CreateProjectOptions.DeserializeCreateProjectOptions(property.Value, options); + continue; + } + if (property.NameEquals("assets"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + assets = Assets.DeserializeAssets(property.Value, options); + continue; + } + if (property.NameEquals("fileUri"u8)) + { + fileUri = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ImportJobOptions(metadata, assets, fileUri, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ImportJobOptions)} does not support writing '{options.Format}' format."); + } + } + + ImportJobOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeImportJobOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ImportJobOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ImportJobOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeImportJobOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ImportJobOptions.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ImportJobOptions.cs new file mode 100644 index 000000000000..418a71b11a35 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ImportJobOptions.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Project assets the needs to be imported. + public partial class ImportJobOptions + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ImportJobOptions() + { + } + + /// Initializes a new instance of . + /// Parameters needed to create the project. + /// All assets for this project. + /// Import data File URI. + /// Keeps track of any properties unknown to the library. + internal ImportJobOptions(CreateProjectOptions metadata, Assets assets, string fileUri, IDictionary serializedAdditionalRawData) + { + Metadata = metadata; + Assets = assets; + FileUri = fileUri; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Parameters needed to create the project. + public CreateProjectOptions Metadata { get; set; } + /// All assets for this project. + public Assets Assets { get; set; } + /// Import data File URI. + public string FileUri { get; set; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ImportQnaRecord.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ImportQnaRecord.Serialization.cs new file mode 100644 index 000000000000..89585c81dc1b --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ImportQnaRecord.Serialization.cs @@ -0,0 +1,294 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class ImportQnaRecord : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ImportQnaRecord)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteNumberValue(Id); + } + if (Optional.IsDefined(Answer)) + { + writer.WritePropertyName("answer"u8); + writer.WriteStringValue(Answer); + } + if (Optional.IsDefined(Source)) + { + writer.WritePropertyName("source"u8); + writer.WriteStringValue(Source); + } + if (Optional.IsCollectionDefined(Questions)) + { + writer.WritePropertyName("questions"u8); + writer.WriteStartArray(); + foreach (var item in Questions) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Dialog)) + { + writer.WritePropertyName("dialog"u8); + writer.WriteObjectValue(Dialog, options); + } + if (Optional.IsCollectionDefined(ActiveLearningSuggestions)) + { + writer.WritePropertyName("activeLearningSuggestions"u8); + writer.WriteStartArray(); + foreach (var item in ActiveLearningSuggestions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(LastUpdatedDateTime)) + { + writer.WritePropertyName("lastUpdatedDateTime"u8); + writer.WriteStringValue(LastUpdatedDateTime.Value, "O"); + } + if (Optional.IsDefined(SourceDisplayName)) + { + writer.WritePropertyName("sourceDisplayName"u8); + writer.WriteStringValue(SourceDisplayName); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ImportQnaRecord IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ImportQnaRecord)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeImportQnaRecord(document.RootElement, options); + } + + internal static ImportQnaRecord DeserializeImportQnaRecord(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int id = default; + string answer = default; + string source = default; + IList questions = default; + IDictionary metadata = default; + QnaDialog dialog = default; + IList activeLearningSuggestions = default; + DateTimeOffset? lastUpdatedDateTime = default; + string sourceDisplayName = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("answer"u8)) + { + answer = property.Value.GetString(); + continue; + } + if (property.NameEquals("source"u8)) + { + source = property.Value.GetString(); + continue; + } + if (property.NameEquals("questions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + questions = array; + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (property.NameEquals("dialog"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dialog = QnaDialog.DeserializeQnaDialog(property.Value, options); + continue; + } + if (property.NameEquals("activeLearningSuggestions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SuggestedQuestionsCluster.DeserializeSuggestedQuestionsCluster(item, options)); + } + activeLearningSuggestions = array; + continue; + } + if (property.NameEquals("lastUpdatedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastUpdatedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("sourceDisplayName"u8)) + { + sourceDisplayName = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ImportQnaRecord( + id, + answer, + source, + questions ?? new ChangeTrackingList(), + metadata ?? new ChangeTrackingDictionary(), + dialog, + activeLearningSuggestions ?? new ChangeTrackingList(), + lastUpdatedDateTime, + sourceDisplayName, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ImportQnaRecord)} does not support writing '{options.Format}' format."); + } + } + + ImportQnaRecord IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeImportQnaRecord(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ImportQnaRecord)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ImportQnaRecord FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeImportQnaRecord(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ImportQnaRecord.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ImportQnaRecord.cs new file mode 100644 index 000000000000..0882ae0acfe4 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ImportQnaRecord.cs @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Import QnA Record. + public partial class ImportQnaRecord + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ImportQnaRecord() + { + Questions = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + ActiveLearningSuggestions = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Unique ID for the QnA. + /// Answer text. + /// + /// Source from which QnA was indexed e.g. + /// https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs . + /// + /// List of questions associated with the answer. + /// + /// Metadata associated with the answer, useful to categorize or filter question + /// answers. + /// + /// Context of a QnA. + /// List of Active Learning suggestions for the QnA. + /// Date-time when the QnA was last updated. + /// Friendly name of the Source. + /// Keeps track of any properties unknown to the library. + internal ImportQnaRecord(int id, string answer, string source, IList questions, IDictionary metadata, QnaDialog dialog, IList activeLearningSuggestions, DateTimeOffset? lastUpdatedDateTime, string sourceDisplayName, IDictionary serializedAdditionalRawData) + { + Id = id; + Answer = answer; + Source = source; + Questions = questions; + Metadata = metadata; + Dialog = dialog; + ActiveLearningSuggestions = activeLearningSuggestions; + LastUpdatedDateTime = lastUpdatedDateTime; + SourceDisplayName = sourceDisplayName; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Unique ID for the QnA. + public int Id { get; } + /// Answer text. + public string Answer { get; set; } + /// + /// Source from which QnA was indexed e.g. + /// https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs . + /// + public string Source { get; set; } + /// List of questions associated with the answer. + public IList Questions { get; } + /// + /// Metadata associated with the answer, useful to categorize or filter question + /// answers. + /// + public IDictionary Metadata { get; } + /// Context of a QnA. + public QnaDialog Dialog { get; set; } + /// List of Active Learning suggestions for the QnA. + public IList ActiveLearningSuggestions { get; } + /// Date-time when the QnA was last updated. + public DateTimeOffset? LastUpdatedDateTime { get; set; } + /// Friendly name of the Source. + public string SourceDisplayName { get; set; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/InnerErrorCode.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/InnerErrorCode.cs similarity index 54% rename from sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/InnerErrorCode.cs rename to sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/InnerErrorCode.cs index 1d841ca2a8e0..028a5d10a2f9 100644 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/InnerErrorCode.cs +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/InnerErrorCode.cs @@ -8,10 +8,10 @@ using System; using System.ComponentModel; -namespace Azure.AI.Language.QuestionAnswering +namespace Azure.AI.Language.QuestionAnswering.Authoring { /// Human-readable error code. - internal readonly partial struct InnerErrorCode : IEquatable + public readonly partial struct InnerErrorCode : IEquatable { private readonly string _value; @@ -28,19 +28,43 @@ public InnerErrorCode(string value) private const string AzureCognitiveSearchNotFoundValue = "AzureCognitiveSearchNotFound"; private const string AzureCognitiveSearchThrottlingValue = "AzureCognitiveSearchThrottling"; private const string ExtractionFailureValue = "ExtractionFailure"; + private const string InvalidRequestBodyFormatValue = "InvalidRequestBodyFormat"; + private const string EmptyRequestValue = "EmptyRequest"; + private const string MissingInputDocumentsValue = "MissingInputDocuments"; + private const string InvalidDocumentValue = "InvalidDocument"; + private const string ModelVersionIncorrectValue = "ModelVersionIncorrect"; + private const string InvalidDocumentBatchValue = "InvalidDocumentBatch"; + private const string UnsupportedLanguageCodeValue = "UnsupportedLanguageCode"; + private const string InvalidCountryHintValue = "InvalidCountryHint"; - /// InvalidRequest. + /// Invalid request error. public static InnerErrorCode InvalidRequest { get; } = new InnerErrorCode(InvalidRequestValue); - /// InvalidParameterValue. + /// Invalid parameter value error. public static InnerErrorCode InvalidParameterValue { get; } = new InnerErrorCode(InvalidParameterValueValue); - /// KnowledgeBaseNotFound. + /// Knowledge base not found error. public static InnerErrorCode KnowledgeBaseNotFound { get; } = new InnerErrorCode(KnowledgeBaseNotFoundValue); - /// AzureCognitiveSearchNotFound. + /// Azure Cognitive Search not found error. public static InnerErrorCode AzureCognitiveSearchNotFound { get; } = new InnerErrorCode(AzureCognitiveSearchNotFoundValue); - /// AzureCognitiveSearchThrottling. + /// Azure Cognitive Search throttling error. public static InnerErrorCode AzureCognitiveSearchThrottling { get; } = new InnerErrorCode(AzureCognitiveSearchThrottlingValue); - /// ExtractionFailure. + /// Extraction failure error. public static InnerErrorCode ExtractionFailure { get; } = new InnerErrorCode(ExtractionFailureValue); + /// Invalid request body format error. + public static InnerErrorCode InvalidRequestBodyFormat { get; } = new InnerErrorCode(InvalidRequestBodyFormatValue); + /// Empty request error. + public static InnerErrorCode EmptyRequest { get; } = new InnerErrorCode(EmptyRequestValue); + /// Missing input documents error. + public static InnerErrorCode MissingInputDocuments { get; } = new InnerErrorCode(MissingInputDocumentsValue); + /// Invalid document error. + public static InnerErrorCode InvalidDocument { get; } = new InnerErrorCode(InvalidDocumentValue); + /// Model version incorrect error. + public static InnerErrorCode ModelVersionIncorrect { get; } = new InnerErrorCode(ModelVersionIncorrectValue); + /// Invalid document batch error. + public static InnerErrorCode InvalidDocumentBatch { get; } = new InnerErrorCode(InvalidDocumentBatchValue); + /// Unsupported language code error. + public static InnerErrorCode UnsupportedLanguageCode { get; } = new InnerErrorCode(UnsupportedLanguageCodeValue); + /// Invalid country hint error. + public static InnerErrorCode InvalidCountryHint { get; } = new InnerErrorCode(InvalidCountryHintValue); /// Determines if two values are the same. public static bool operator ==(InnerErrorCode left, InnerErrorCode right) => left.Equals(right); /// Determines if two values are not the same. diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/InnerErrorModel.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/InnerErrorModel.Serialization.cs new file mode 100644 index 000000000000..66f45ce475d8 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/InnerErrorModel.Serialization.cs @@ -0,0 +1,208 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class InnerErrorModel : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InnerErrorModel)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code.ToString()); + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + if (Optional.IsCollectionDefined(Details)) + { + writer.WritePropertyName("details"u8); + writer.WriteStartObject(); + foreach (var item in Details) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Target)) + { + writer.WritePropertyName("target"u8); + writer.WriteStringValue(Target); + } + if (Optional.IsDefined(Innererror)) + { + writer.WritePropertyName("innererror"u8); + writer.WriteObjectValue(Innererror, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InnerErrorModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InnerErrorModel)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInnerErrorModel(document.RootElement, options); + } + + internal static InnerErrorModel DeserializeInnerErrorModel(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InnerErrorCode code = default; + string message = default; + IReadOnlyDictionary details = default; + string target = default; + InnerErrorModel innererror = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code"u8)) + { + code = new InnerErrorCode(property.Value.GetString()); + continue; + } + if (property.NameEquals("message"u8)) + { + message = property.Value.GetString(); + continue; + } + if (property.NameEquals("details"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + details = dictionary; + continue; + } + if (property.NameEquals("target"u8)) + { + target = property.Value.GetString(); + continue; + } + if (property.NameEquals("innererror"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + innererror = DeserializeInnerErrorModel(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InnerErrorModel( + code, + message, + details ?? new ChangeTrackingDictionary(), + target, + innererror, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InnerErrorModel)} does not support writing '{options.Format}' format."); + } + } + + InnerErrorModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInnerErrorModel(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InnerErrorModel)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static InnerErrorModel FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInnerErrorModel(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/InnerErrorModel.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/InnerErrorModel.cs new file mode 100644 index 000000000000..0b97a22b2560 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/InnerErrorModel.cs @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// + /// An object containing more specific information about the error. As per + /// Microsoft One API guidelines - + /// https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. + /// + public partial class InnerErrorModel + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// One of a server-defined set of error codes. + /// Error message. + /// is null. + internal InnerErrorModel(InnerErrorCode code, string message) + { + Argument.AssertNotNull(message, nameof(message)); + + Code = code; + Message = message; + Details = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// One of a server-defined set of error codes. + /// Error message. + /// Error details. + /// Error target. + /// + /// An object containing more specific information than the current object about + /// the error. + /// + /// Keeps track of any properties unknown to the library. + internal InnerErrorModel(InnerErrorCode code, string message, IReadOnlyDictionary details, string target, InnerErrorModel innererror, IDictionary serializedAdditionalRawData) + { + Code = code; + Message = message; + Details = details; + Target = target; + Innererror = innererror; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InnerErrorModel() + { + } + + /// One of a server-defined set of error codes. + public InnerErrorCode Code { get; } + /// Error message. + public string Message { get; } + /// Error details. + public IReadOnlyDictionary Details { get; } + /// Error target. + public string Target { get; } + /// + /// An object containing more specific information than the current object about + /// the error. + /// + public InnerErrorModel Innererror { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Internal/Argument.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..f2bb6e6d3881 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Internal/Argument.cs @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + internal static class Argument + { + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", name); + } + } + + public static void AssertNotNullOrWhiteSpace(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); + } + } + + public static void AssertNotDefault(ref T value, string name) + where T : struct, IEquatable + { + if (value.Equals(default)) + { + throw new ArgumentException("Value cannot be empty.", name); + } + } + + public static void AssertInRange(T value, T minimum, T maximum, string name) + where T : notnull, IComparable + { + if (minimum.CompareTo(value) > 0) + { + throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); + } + if (maximum.CompareTo(value) < 0) + { + throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); + } + } + + public static void AssertEnumDefined(Type enumType, object value, string name) + { + if (!Enum.IsDefined(enumType, value)) + { + throw new ArgumentException($"Value not defined for {enumType.FullName}.", name); + } + } + + public static T CheckNotNull(T value, string name) + where T : class + { + AssertNotNull(value, name); + return value; + } + + public static string CheckNotNullOrEmpty(string value, string name) + { + AssertNotNullOrEmpty(value, name); + return value; + } + + public static void AssertNull(T value, string name, string message = null) + { + if (value != null) + { + throw new ArgumentException(message ?? "Value must be null.", name); + } + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..a95cfdefa577 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + public bool IsUndefined => _innerDictionary == null; + + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + IEnumerable IReadOnlyDictionary.Keys => Keys; + + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Internal/ChangeTrackingList.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..05e33507650c --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + internal class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + public bool IsUndefined => _innerList == null; + + public int Count => IsUndefined ? 0 : EnsureList().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..9a4904669a4e --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,399 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text.Json; +using System.Xml; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + internal static class ModelSerializationExtensions + { + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + var dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + var list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + var text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + { + throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + var value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case IUtf8JsonSerializable serializable: + serializable.Write(writer); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + internal static class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Azure SDK requires it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; + int size = checked(numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ConvertToString(object value, string format = null) => value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when format != null => ToString(b0, format), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when format != null => ToString(dateTime, format), + TimeSpan timeSpan when format != null => ToString(timeSpan, format), + TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Internal/Optional.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..f36a5fc0ef95 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + internal static class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + + public static bool IsDefined(string value) + { + return value != null; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..977c454f39ed --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.IO; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + internal class Utf8JsonRequestContent : RequestContent + { + private readonly MemoryStream _stream; + private readonly RequestContent _content; + + public Utf8JsonRequestContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + public Utf8JsonWriter JsonWriter { get; } + + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { + JsonWriter.Flush(); + _content.WriteTo(stream, cancellationToken); + } + + public override bool TryComputeLength(out long length) + { + length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; + return true; + } + + public override void Dispose() + { + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/JobStatus.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/JobStatus.cs new file mode 100644 index 000000000000..62fe180f22fe --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/JobStatus.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Job Status. + public readonly partial struct JobStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public JobStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NotStartedValue = "notStarted"; + private const string RunningValue = "running"; + private const string SucceededValue = "succeeded"; + private const string FailedValue = "failed"; + private const string CancelledValue = "cancelled"; + private const string CancellingValue = "cancelling"; + private const string PartiallyCompletedValue = "partiallyCompleted"; + + /// notStarted. + public static JobStatus NotStarted { get; } = new JobStatus(NotStartedValue); + /// running. + public static JobStatus Running { get; } = new JobStatus(RunningValue); + /// succeeded. + public static JobStatus Succeeded { get; } = new JobStatus(SucceededValue); + /// failed. + public static JobStatus Failed { get; } = new JobStatus(FailedValue); + /// cancelled. + public static JobStatus Cancelled { get; } = new JobStatus(CancelledValue); + /// cancelling. + public static JobStatus Cancelling { get; } = new JobStatus(CancellingValue); + /// partiallyCompleted. + public static JobStatus PartiallyCompleted { get; } = new JobStatus(PartiallyCompletedValue); + /// Determines if two values are the same. + public static bool operator ==(JobStatus left, JobStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(JobStatus left, JobStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator JobStatus(string value) => new JobStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is JobStatus other && Equals(other); + /// + public bool Equals(JobStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ProjectDeployment.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ProjectDeployment.Serialization.cs new file mode 100644 index 000000000000..864b46f1867e --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ProjectDeployment.Serialization.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class ProjectDeployment : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProjectDeployment)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("deploymentName"u8); + writer.WriteStringValue(DeploymentName); + } + if (Optional.IsDefined(LastDeployedDateTime)) + { + writer.WritePropertyName("lastDeployedDateTime"u8); + writer.WriteStringValue(LastDeployedDateTime.Value, "O"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ProjectDeployment IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProjectDeployment)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProjectDeployment(document.RootElement, options); + } + + internal static ProjectDeployment DeserializeProjectDeployment(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string deploymentName = default; + DateTimeOffset? lastDeployedDateTime = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("deploymentName"u8)) + { + deploymentName = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastDeployedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastDeployedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ProjectDeployment(deploymentName, lastDeployedDateTime, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ProjectDeployment)} does not support writing '{options.Format}' format."); + } + } + + ProjectDeployment IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeProjectDeployment(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProjectDeployment)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ProjectDeployment FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeProjectDeployment(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ProjectDeployment.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ProjectDeployment.cs new file mode 100644 index 000000000000..6d87a084b919 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ProjectDeployment.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Project deployment details. + public partial class ProjectDeployment + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal ProjectDeployment() + { + } + + /// Initializes a new instance of . + /// Name of the deployment. + /// Represents the project last deployment date-time. + /// Keeps track of any properties unknown to the library. + internal ProjectDeployment(string deploymentName, DateTimeOffset? lastDeployedDateTime, IDictionary serializedAdditionalRawData) + { + DeploymentName = deploymentName; + LastDeployedDateTime = lastDeployedDateTime; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Name of the deployment. + public string DeploymentName { get; } + /// Represents the project last deployment date-time. + public DateTimeOffset? LastDeployedDateTime { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ProjectMetadata.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ProjectMetadata.Serialization.cs new file mode 100644 index 000000000000..f08c3d825f1c --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ProjectMetadata.Serialization.cs @@ -0,0 +1,251 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class ProjectMetadata : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProjectMetadata)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("projectName"u8); + writer.WriteStringValue(ProjectName); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(Language)) + { + writer.WritePropertyName("language"u8); + writer.WriteStringValue(Language); + } + if (Optional.IsDefined(MultilingualResource)) + { + writer.WritePropertyName("multilingualResource"u8); + writer.WriteBooleanValue(MultilingualResource.Value); + } + if (Optional.IsDefined(Settings)) + { + writer.WritePropertyName("settings"u8); + writer.WriteObjectValue(Settings, options); + } + if (Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (Optional.IsDefined(LastModifiedDateTime)) + { + writer.WritePropertyName("lastModifiedDateTime"u8); + writer.WriteStringValue(LastModifiedDateTime.Value, "O"); + } + if (Optional.IsDefined(LastDeployedDateTime)) + { + writer.WritePropertyName("lastDeployedDateTime"u8); + writer.WriteStringValue(LastDeployedDateTime.Value, "O"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ProjectMetadata IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProjectMetadata)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProjectMetadata(document.RootElement, options); + } + + internal static ProjectMetadata DeserializeProjectMetadata(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string projectName = default; + string description = default; + string language = default; + bool? multilingualResource = default; + ProjectSettings settings = default; + DateTimeOffset? createdDateTime = default; + DateTimeOffset? lastModifiedDateTime = default; + DateTimeOffset? lastDeployedDateTime = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("projectName"u8)) + { + projectName = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("language"u8)) + { + language = property.Value.GetString(); + continue; + } + if (property.NameEquals("multilingualResource"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + multilingualResource = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("settings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + settings = ProjectSettings.DeserializeProjectSettings(property.Value, options); + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastDeployedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastDeployedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ProjectMetadata( + projectName, + description, + language, + multilingualResource, + settings, + createdDateTime, + lastModifiedDateTime, + lastDeployedDateTime, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ProjectMetadata)} does not support writing '{options.Format}' format."); + } + } + + ProjectMetadata IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeProjectMetadata(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProjectMetadata)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ProjectMetadata FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeProjectMetadata(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ProjectMetadata.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ProjectMetadata.cs new file mode 100644 index 000000000000..ee104c399edb --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ProjectMetadata.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Represents the project. + public partial class ProjectMetadata + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal ProjectMetadata() + { + } + + /// Initializes a new instance of . + /// Name of the project. + /// Description of the project. + /// + /// Language of the text records. This is BCP-47 representation of a language. For + /// example, use "en" for English; "es" for Spanish etc. If not set, use "en" for + /// English as default. + /// + /// Resource enabled for multiple languages across projects or not. + /// Configurable settings of the Project. + /// Project creation date-time. + /// Represents the project last modified date-time. + /// Represents the project last deployment date-time. + /// Keeps track of any properties unknown to the library. + internal ProjectMetadata(string projectName, string description, string language, bool? multilingualResource, ProjectSettings settings, DateTimeOffset? createdDateTime, DateTimeOffset? lastModifiedDateTime, DateTimeOffset? lastDeployedDateTime, IDictionary serializedAdditionalRawData) + { + ProjectName = projectName; + Description = description; + Language = language; + MultilingualResource = multilingualResource; + Settings = settings; + CreatedDateTime = createdDateTime; + LastModifiedDateTime = lastModifiedDateTime; + LastDeployedDateTime = lastDeployedDateTime; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Name of the project. + public string ProjectName { get; } + /// Description of the project. + public string Description { get; } + /// + /// Language of the text records. This is BCP-47 representation of a language. For + /// example, use "en" for English; "es" for Spanish etc. If not set, use "en" for + /// English as default. + /// + public string Language { get; } + /// Resource enabled for multiple languages across projects or not. + public bool? MultilingualResource { get; } + /// Configurable settings of the Project. + public ProjectSettings Settings { get; } + /// Project creation date-time. + public DateTimeOffset? CreatedDateTime { get; } + /// Represents the project last modified date-time. + public DateTimeOffset? LastModifiedDateTime { get; } + /// Represents the project last deployment date-time. + public DateTimeOffset? LastDeployedDateTime { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ProjectSettings.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ProjectSettings.Serialization.cs new file mode 100644 index 000000000000..c5da3779cbad --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ProjectSettings.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class ProjectSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProjectSettings)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(DefaultAnswer)) + { + writer.WritePropertyName("defaultAnswer"u8); + writer.WriteStringValue(DefaultAnswer); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ProjectSettings IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProjectSettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProjectSettings(document.RootElement, options); + } + + internal static ProjectSettings DeserializeProjectSettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string defaultAnswer = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("defaultAnswer"u8)) + { + defaultAnswer = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ProjectSettings(defaultAnswer, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ProjectSettings)} does not support writing '{options.Format}' format."); + } + } + + ProjectSettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeProjectSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProjectSettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ProjectSettings FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeProjectSettings(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ProjectSettings.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ProjectSettings.cs new file mode 100644 index 000000000000..5998196022e9 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/ProjectSettings.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Configurable settings of the Project. + public partial class ProjectSettings + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ProjectSettings() + { + } + + /// Initializes a new instance of . + /// Default Answer response when no good match is found in the knowledge base. + /// Keeps track of any properties unknown to the library. + internal ProjectSettings(string defaultAnswer, IDictionary serializedAdditionalRawData) + { + DefaultAnswer = defaultAnswer; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Default Answer response when no good match is found in the knowledge base. + public string DefaultAnswer { get; set; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaDialog.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaDialog.Serialization.cs new file mode 100644 index 000000000000..4c40c2706c27 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaDialog.Serialization.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class QnaDialog : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QnaDialog)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(IsContextOnly)) + { + writer.WritePropertyName("isContextOnly"u8); + writer.WriteBooleanValue(IsContextOnly.Value); + } + if (Optional.IsCollectionDefined(Prompts)) + { + writer.WritePropertyName("prompts"u8); + writer.WriteStartArray(); + foreach (var item in Prompts) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + QnaDialog IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QnaDialog)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQnaDialog(document.RootElement, options); + } + + internal static QnaDialog DeserializeQnaDialog(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? isContextOnly = default; + IList prompts = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("isContextOnly"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isContextOnly = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("prompts"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(QnaPrompt.DeserializeQnaPrompt(item, options)); + } + prompts = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new QnaDialog(isContextOnly, prompts ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(QnaDialog)} does not support writing '{options.Format}' format."); + } + } + + QnaDialog IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQnaDialog(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QnaDialog)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static QnaDialog FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQnaDialog(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaDialog.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaDialog.cs new file mode 100644 index 000000000000..c3d3844541fa --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaDialog.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Dialog associated with QnA Record. + public partial class QnaDialog + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public QnaDialog() + { + Prompts = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// To mark if a prompt is relevant only with a previous question or not. If true, + /// do not include this QnA as answer for queries without context; otherwise, + /// ignores context and includes this QnA in answers. + /// + /// List of prompts associated with the answer. + /// Keeps track of any properties unknown to the library. + internal QnaDialog(bool? isContextOnly, IList prompts, IDictionary serializedAdditionalRawData) + { + IsContextOnly = isContextOnly; + Prompts = prompts; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// To mark if a prompt is relevant only with a previous question or not. If true, + /// do not include this QnA as answer for queries without context; otherwise, + /// ignores context and includes this QnA in answers. + /// + public bool? IsContextOnly { get; set; } + /// List of prompts associated with the answer. + public IList Prompts { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaPrompt.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaPrompt.Serialization.cs new file mode 100644 index 000000000000..7d282f552961 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaPrompt.Serialization.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class QnaPrompt : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QnaPrompt)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(DisplayOrder)) + { + writer.WritePropertyName("displayOrder"u8); + writer.WriteNumberValue(DisplayOrder.Value); + } + if (Optional.IsDefined(QnaId)) + { + writer.WritePropertyName("qnaId"u8); + writer.WriteNumberValue(QnaId.Value); + } + if (Optional.IsDefined(Qna)) + { + writer.WritePropertyName("qna"u8); + writer.WriteObjectValue(Qna, options); + } + if (Optional.IsDefined(DisplayText)) + { + writer.WritePropertyName("displayText"u8); + writer.WriteStringValue(DisplayText); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + QnaPrompt IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QnaPrompt)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQnaPrompt(document.RootElement, options); + } + + internal static QnaPrompt DeserializeQnaPrompt(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? displayOrder = default; + int? qnaId = default; + QnaRecord qna = default; + string displayText = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("displayOrder"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + displayOrder = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("qnaId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + qnaId = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("qna"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + qna = QnaRecord.DeserializeQnaRecord(property.Value, options); + continue; + } + if (property.NameEquals("displayText"u8)) + { + displayText = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new QnaPrompt(displayOrder, qnaId, qna, displayText, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(QnaPrompt)} does not support writing '{options.Format}' format."); + } + } + + QnaPrompt IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQnaPrompt(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QnaPrompt)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static QnaPrompt FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQnaPrompt(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaPrompt.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaPrompt.cs new file mode 100644 index 000000000000..500c887445da --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaPrompt.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Prompt for an answer. + public partial class QnaPrompt + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public QnaPrompt() + { + } + + /// Initializes a new instance of . + /// Index of the prompt. It is used for ordering of the prompts. + /// ID of the QnA corresponding to the prompt. + /// QnA record. Either QnAId or QnA record needs to be present in a Prompt. + /// Text displayed to represent a follow up question prompt. + /// Keeps track of any properties unknown to the library. + internal QnaPrompt(int? displayOrder, int? qnaId, QnaRecord qna, string displayText, IDictionary serializedAdditionalRawData) + { + DisplayOrder = displayOrder; + QnaId = qnaId; + Qna = qna; + DisplayText = displayText; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Index of the prompt. It is used for ordering of the prompts. + public int? DisplayOrder { get; set; } + /// ID of the QnA corresponding to the prompt. + public int? QnaId { get; set; } + /// QnA record. Either QnAId or QnA record needs to be present in a Prompt. + public QnaRecord Qna { get; set; } + /// Text displayed to represent a follow up question prompt. + public string DisplayText { get; set; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaRecord.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaRecord.Serialization.cs new file mode 100644 index 000000000000..ab842aeade01 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaRecord.Serialization.cs @@ -0,0 +1,266 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class QnaRecord : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QnaRecord)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteNumberValue(Id); + } + if (Optional.IsDefined(Answer)) + { + writer.WritePropertyName("answer"u8); + writer.WriteStringValue(Answer); + } + if (Optional.IsDefined(Source)) + { + writer.WritePropertyName("source"u8); + writer.WriteStringValue(Source); + } + if (Optional.IsCollectionDefined(Questions)) + { + writer.WritePropertyName("questions"u8); + writer.WriteStartArray(); + foreach (var item in Questions) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Dialog)) + { + writer.WritePropertyName("dialog"u8); + writer.WriteObjectValue(Dialog, options); + } + if (Optional.IsCollectionDefined(ActiveLearningSuggestions)) + { + writer.WritePropertyName("activeLearningSuggestions"u8); + writer.WriteStartArray(); + foreach (var item in ActiveLearningSuggestions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + QnaRecord IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QnaRecord)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQnaRecord(document.RootElement, options); + } + + internal static QnaRecord DeserializeQnaRecord(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int id = default; + string answer = default; + string source = default; + IList questions = default; + IDictionary metadata = default; + QnaDialog dialog = default; + IList activeLearningSuggestions = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("answer"u8)) + { + answer = property.Value.GetString(); + continue; + } + if (property.NameEquals("source"u8)) + { + source = property.Value.GetString(); + continue; + } + if (property.NameEquals("questions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + questions = array; + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (property.NameEquals("dialog"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dialog = QnaDialog.DeserializeQnaDialog(property.Value, options); + continue; + } + if (property.NameEquals("activeLearningSuggestions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SuggestedQuestionsCluster.DeserializeSuggestedQuestionsCluster(item, options)); + } + activeLearningSuggestions = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new QnaRecord( + id, + answer, + source, + questions ?? new ChangeTrackingList(), + metadata ?? new ChangeTrackingDictionary(), + dialog, + activeLearningSuggestions ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(QnaRecord)} does not support writing '{options.Format}' format."); + } + } + + QnaRecord IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQnaRecord(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QnaRecord)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static QnaRecord FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQnaRecord(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaRecord.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaRecord.cs new file mode 100644 index 000000000000..74c5d281548a --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaRecord.cs @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// QnA record. + public partial class QnaRecord + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public QnaRecord() + { + Questions = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + ActiveLearningSuggestions = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Unique ID for the QnA. + /// Answer text. + /// + /// Source from which QnA was indexed e.g. + /// https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs . + /// + /// List of questions associated with the answer. + /// + /// Metadata associated with the answer, useful to categorize or filter question + /// answers. + /// + /// Context of a QnA. + /// List of Active Learning suggestions for the QnA. + /// Keeps track of any properties unknown to the library. + internal QnaRecord(int id, string answer, string source, IList questions, IDictionary metadata, QnaDialog dialog, IList activeLearningSuggestions, IDictionary serializedAdditionalRawData) + { + Id = id; + Answer = answer; + Source = source; + Questions = questions; + Metadata = metadata; + Dialog = dialog; + ActiveLearningSuggestions = activeLearningSuggestions; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Unique ID for the QnA. + public int Id { get; } + /// Answer text. + public string Answer { get; set; } + /// + /// Source from which QnA was indexed e.g. + /// https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs . + /// + public string Source { get; set; } + /// List of questions associated with the answer. + public IList Questions { get; } + /// + /// Metadata associated with the answer, useful to categorize or filter question + /// answers. + /// + public IDictionary Metadata { get; } + /// Context of a QnA. + public QnaDialog Dialog { get; set; } + /// List of Active Learning suggestions for the QnA. + public IList ActiveLearningSuggestions { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaSourceRecord.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaSourceRecord.Serialization.cs new file mode 100644 index 000000000000..a1148178c7d0 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaSourceRecord.Serialization.cs @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class QnaSourceRecord : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QnaSourceRecord)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + writer.WritePropertyName("source"u8); + writer.WriteStringValue(Source); + writer.WritePropertyName("sourceUri"u8); + writer.WriteStringValue(SourceUri.AbsoluteUri); + writer.WritePropertyName("sourceKind"u8); + writer.WriteStringValue(SourceKind.ToString()); + if (Optional.IsDefined(ContentStructureKind)) + { + writer.WritePropertyName("contentStructureKind"u8); + writer.WriteStringValue(ContentStructureKind.Value.ToString()); + } + if (Optional.IsDefined(LastUpdatedDateTime)) + { + writer.WritePropertyName("lastUpdatedDateTime"u8); + writer.WriteStringValue(LastUpdatedDateTime.Value, "O"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + QnaSourceRecord IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QnaSourceRecord)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQnaSourceRecord(document.RootElement, options); + } + + internal static QnaSourceRecord DeserializeQnaSourceRecord(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string displayName = default; + string source = default; + Uri sourceUri = default; + SourceKind sourceKind = default; + SourceContentStructureKind? contentStructureKind = default; + DateTimeOffset? lastUpdatedDateTime = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("source"u8)) + { + source = property.Value.GetString(); + continue; + } + if (property.NameEquals("sourceUri"u8)) + { + sourceUri = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("sourceKind"u8)) + { + sourceKind = new SourceKind(property.Value.GetString()); + continue; + } + if (property.NameEquals("contentStructureKind"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + contentStructureKind = new SourceContentStructureKind(property.Value.GetString()); + continue; + } + if (property.NameEquals("lastUpdatedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastUpdatedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new QnaSourceRecord( + displayName, + source, + sourceUri, + sourceKind, + contentStructureKind, + lastUpdatedDateTime, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(QnaSourceRecord)} does not support writing '{options.Format}' format."); + } + } + + QnaSourceRecord IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQnaSourceRecord(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QnaSourceRecord)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static QnaSourceRecord FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQnaSourceRecord(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaSourceRecord.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaSourceRecord.cs new file mode 100644 index 000000000000..16bdcfef5981 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QnaSourceRecord.cs @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Custom source record with last updated date-time. + public partial class QnaSourceRecord + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// + /// Unique source identifier. Name of the file if it's a 'file' source; otherwise, + /// the complete URL if it's a 'url' source. + /// + /// URI location for the file or url. + /// Supported source types. + /// or is null. + internal QnaSourceRecord(string source, Uri sourceUri, SourceKind sourceKind) + { + Argument.AssertNotNull(source, nameof(source)); + Argument.AssertNotNull(sourceUri, nameof(sourceUri)); + + Source = source; + SourceUri = sourceUri; + SourceKind = sourceKind; + } + + /// Initializes a new instance of . + /// Friendly name of the Source. + /// + /// Unique source identifier. Name of the file if it's a 'file' source; otherwise, + /// the complete URL if it's a 'url' source. + /// + /// URI location for the file or url. + /// Supported source types. + /// Content structure type for sources. + /// Date-time when the QnA was last updated. + /// Keeps track of any properties unknown to the library. + internal QnaSourceRecord(string displayName, string source, Uri sourceUri, SourceKind sourceKind, SourceContentStructureKind? contentStructureKind, DateTimeOffset? lastUpdatedDateTime, IDictionary serializedAdditionalRawData) + { + DisplayName = displayName; + Source = source; + SourceUri = sourceUri; + SourceKind = sourceKind; + ContentStructureKind = contentStructureKind; + LastUpdatedDateTime = lastUpdatedDateTime; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal QnaSourceRecord() + { + } + + /// Friendly name of the Source. + public string DisplayName { get; } + /// + /// Unique source identifier. Name of the file if it's a 'file' source; otherwise, + /// the complete URL if it's a 'url' source. + /// + public string Source { get; } + /// URI location for the file or url. + public Uri SourceUri { get; } + /// Supported source types. + public SourceKind SourceKind { get; } + /// Content structure type for sources. + public SourceContentStructureKind? ContentStructureKind { get; } + /// Date-time when the QnA was last updated. + public DateTimeOffset? LastUpdatedDateTime { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringExportJobState.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringExportJobState.Serialization.cs new file mode 100644 index 000000000000..73fb5151f958 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringExportJobState.Serialization.cs @@ -0,0 +1,225 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class QuestionAnsweringAuthoringExportJobState : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringExportJobState)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime, "O"); + if (Optional.IsDefined(ExpirationDateTime)) + { + writer.WritePropertyName("expirationDateTime"u8); + writer.WriteStringValue(ExpirationDateTime.Value, "O"); + } + if (options.Format != "W") + { + writer.WritePropertyName("jobId"u8); + writer.WriteStringValue(JobId); + } + writer.WritePropertyName("lastUpdatedDateTime"u8); + writer.WriteStringValue(LastUpdatedDateTime, "O"); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + if (Optional.IsCollectionDefined(Errors)) + { + writer.WritePropertyName("errors"u8); + writer.WriteStartArray(); + foreach (var item in Errors) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("resultUrl"u8); + writer.WriteStringValue(ResultUrl); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + QuestionAnsweringAuthoringExportJobState IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringExportJobState)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQuestionAnsweringAuthoringExportJobState(document.RootElement, options); + } + + internal static QuestionAnsweringAuthoringExportJobState DeserializeQuestionAnsweringAuthoringExportJobState(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset createdDateTime = default; + DateTimeOffset? expirationDateTime = default; + string jobId = default; + DateTimeOffset lastUpdatedDateTime = default; + JobStatus status = default; + IReadOnlyList errors = default; + string resultUrl = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("createdDateTime"u8)) + { + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("expirationDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expirationDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("jobId"u8)) + { + jobId = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastUpdatedDateTime"u8)) + { + lastUpdatedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new JobStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("errors"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Error.DeserializeError(item, options)); + } + errors = array; + continue; + } + if (property.NameEquals("resultUrl"u8)) + { + resultUrl = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new QuestionAnsweringAuthoringExportJobState( + createdDateTime, + expirationDateTime, + jobId, + lastUpdatedDateTime, + status, + errors ?? new ChangeTrackingList(), + resultUrl, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringExportJobState)} does not support writing '{options.Format}' format."); + } + } + + QuestionAnsweringAuthoringExportJobState IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQuestionAnsweringAuthoringExportJobState(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringExportJobState)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static QuestionAnsweringAuthoringExportJobState FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQuestionAnsweringAuthoringExportJobState(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringExportJobState.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringExportJobState.cs new file mode 100644 index 000000000000..c9a8074c79a5 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringExportJobState.cs @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Export job status, project metadata, and assets. + public partial class QuestionAnsweringAuthoringExportJobState + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The creation date time of the job. + /// The last date time the job was updated. + /// Job Status. + /// URL to download the result of the Export Job. + /// is null. + internal QuestionAnsweringAuthoringExportJobState(DateTimeOffset createdDateTime, DateTimeOffset lastUpdatedDateTime, JobStatus status, string resultUrl) + { + Argument.AssertNotNull(resultUrl, nameof(resultUrl)); + + CreatedDateTime = createdDateTime; + LastUpdatedDateTime = lastUpdatedDateTime; + Status = status; + Errors = new ChangeTrackingList(); + ResultUrl = resultUrl; + } + + /// Initializes a new instance of . + /// The creation date time of the job. + /// The expiration date time of the job. + /// The job ID. + /// The last date time the job was updated. + /// Job Status. + /// The errors encountered while executing the job. + /// URL to download the result of the Export Job. + /// Keeps track of any properties unknown to the library. + internal QuestionAnsweringAuthoringExportJobState(DateTimeOffset createdDateTime, DateTimeOffset? expirationDateTime, string jobId, DateTimeOffset lastUpdatedDateTime, JobStatus status, IReadOnlyList errors, string resultUrl, IDictionary serializedAdditionalRawData) + { + CreatedDateTime = createdDateTime; + ExpirationDateTime = expirationDateTime; + JobId = jobId; + LastUpdatedDateTime = lastUpdatedDateTime; + Status = status; + Errors = errors; + ResultUrl = resultUrl; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal QuestionAnsweringAuthoringExportJobState() + { + } + + /// The creation date time of the job. + public DateTimeOffset CreatedDateTime { get; } + /// The expiration date time of the job. + public DateTimeOffset? ExpirationDateTime { get; } + /// The job ID. + public string JobId { get; } + /// The last date time the job was updated. + public DateTimeOffset LastUpdatedDateTime { get; } + /// Job Status. + public JobStatus Status { get; } + /// The errors encountered while executing the job. + public IReadOnlyList Errors { get; } + /// URL to download the result of the Export Job. + public string ResultUrl { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringImportJobState.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringImportJobState.Serialization.cs new file mode 100644 index 000000000000..c0c677286bda --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringImportJobState.Serialization.cs @@ -0,0 +1,216 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class QuestionAnsweringAuthoringImportJobState : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringImportJobState)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime, "O"); + if (Optional.IsDefined(ExpirationDateTime)) + { + writer.WritePropertyName("expirationDateTime"u8); + writer.WriteStringValue(ExpirationDateTime.Value, "O"); + } + if (options.Format != "W") + { + writer.WritePropertyName("jobId"u8); + writer.WriteStringValue(JobId); + } + writer.WritePropertyName("lastUpdatedDateTime"u8); + writer.WriteStringValue(LastUpdatedDateTime, "O"); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + if (Optional.IsCollectionDefined(Errors)) + { + writer.WritePropertyName("errors"u8); + writer.WriteStartArray(); + foreach (var item in Errors) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + QuestionAnsweringAuthoringImportJobState IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringImportJobState)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQuestionAnsweringAuthoringImportJobState(document.RootElement, options); + } + + internal static QuestionAnsweringAuthoringImportJobState DeserializeQuestionAnsweringAuthoringImportJobState(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset createdDateTime = default; + DateTimeOffset? expirationDateTime = default; + string jobId = default; + DateTimeOffset lastUpdatedDateTime = default; + JobStatus status = default; + IReadOnlyList errors = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("createdDateTime"u8)) + { + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("expirationDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expirationDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("jobId"u8)) + { + jobId = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastUpdatedDateTime"u8)) + { + lastUpdatedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new JobStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("errors"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Error.DeserializeError(item, options)); + } + errors = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new QuestionAnsweringAuthoringImportJobState( + createdDateTime, + expirationDateTime, + jobId, + lastUpdatedDateTime, + status, + errors ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringImportJobState)} does not support writing '{options.Format}' format."); + } + } + + QuestionAnsweringAuthoringImportJobState IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQuestionAnsweringAuthoringImportJobState(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringImportJobState)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static QuestionAnsweringAuthoringImportJobState FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQuestionAnsweringAuthoringImportJobState(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringImportJobState.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringImportJobState.cs new file mode 100644 index 000000000000..d6658d526a61 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringImportJobState.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Import job status, project metadata, and assets. + public partial class QuestionAnsweringAuthoringImportJobState + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The creation date time of the job. + /// The last date time the job was updated. + /// Job Status. + internal QuestionAnsweringAuthoringImportJobState(DateTimeOffset createdDateTime, DateTimeOffset lastUpdatedDateTime, JobStatus status) + { + CreatedDateTime = createdDateTime; + LastUpdatedDateTime = lastUpdatedDateTime; + Status = status; + Errors = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The creation date time of the job. + /// The expiration date time of the job. + /// The job ID. + /// The last date time the job was updated. + /// Job Status. + /// The errors encountered while executing the job. + /// Keeps track of any properties unknown to the library. + internal QuestionAnsweringAuthoringImportJobState(DateTimeOffset createdDateTime, DateTimeOffset? expirationDateTime, string jobId, DateTimeOffset lastUpdatedDateTime, JobStatus status, IReadOnlyList errors, IDictionary serializedAdditionalRawData) + { + CreatedDateTime = createdDateTime; + ExpirationDateTime = expirationDateTime; + JobId = jobId; + LastUpdatedDateTime = lastUpdatedDateTime; + Status = status; + Errors = errors; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal QuestionAnsweringAuthoringImportJobState() + { + } + + /// The creation date time of the job. + public DateTimeOffset CreatedDateTime { get; } + /// The expiration date time of the job. + public DateTimeOffset? ExpirationDateTime { get; } + /// The job ID. + public string JobId { get; } + /// The last date time the job was updated. + public DateTimeOffset LastUpdatedDateTime { get; } + /// Job Status. + public JobStatus Status { get; } + /// The errors encountered while executing the job. + public IReadOnlyList Errors { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringProjectDeletionJobState.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringProjectDeletionJobState.Serialization.cs new file mode 100644 index 000000000000..a6ff063c9132 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringProjectDeletionJobState.Serialization.cs @@ -0,0 +1,216 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class QuestionAnsweringAuthoringProjectDeletionJobState : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringProjectDeletionJobState)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime, "O"); + if (Optional.IsDefined(ExpirationDateTime)) + { + writer.WritePropertyName("expirationDateTime"u8); + writer.WriteStringValue(ExpirationDateTime.Value, "O"); + } + if (options.Format != "W") + { + writer.WritePropertyName("jobId"u8); + writer.WriteStringValue(JobId); + } + writer.WritePropertyName("lastUpdatedDateTime"u8); + writer.WriteStringValue(LastUpdatedDateTime, "O"); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + if (Optional.IsCollectionDefined(Errors)) + { + writer.WritePropertyName("errors"u8); + writer.WriteStartArray(); + foreach (var item in Errors) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + QuestionAnsweringAuthoringProjectDeletionJobState IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringProjectDeletionJobState)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQuestionAnsweringAuthoringProjectDeletionJobState(document.RootElement, options); + } + + internal static QuestionAnsweringAuthoringProjectDeletionJobState DeserializeQuestionAnsweringAuthoringProjectDeletionJobState(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset createdDateTime = default; + DateTimeOffset? expirationDateTime = default; + string jobId = default; + DateTimeOffset lastUpdatedDateTime = default; + JobStatus status = default; + IReadOnlyList errors = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("createdDateTime"u8)) + { + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("expirationDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expirationDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("jobId"u8)) + { + jobId = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastUpdatedDateTime"u8)) + { + lastUpdatedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new JobStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("errors"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Error.DeserializeError(item, options)); + } + errors = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new QuestionAnsweringAuthoringProjectDeletionJobState( + createdDateTime, + expirationDateTime, + jobId, + lastUpdatedDateTime, + status, + errors ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringProjectDeletionJobState)} does not support writing '{options.Format}' format."); + } + } + + QuestionAnsweringAuthoringProjectDeletionJobState IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQuestionAnsweringAuthoringProjectDeletionJobState(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringProjectDeletionJobState)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static QuestionAnsweringAuthoringProjectDeletionJobState FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQuestionAnsweringAuthoringProjectDeletionJobState(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringProjectDeletionJobState.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringProjectDeletionJobState.cs new file mode 100644 index 000000000000..bed301350faa --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringProjectDeletionJobState.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Represents the state of a project deletion job. + public partial class QuestionAnsweringAuthoringProjectDeletionJobState + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The creation date time of the job. + /// The last date time the job was updated. + /// Job Status. + internal QuestionAnsweringAuthoringProjectDeletionJobState(DateTimeOffset createdDateTime, DateTimeOffset lastUpdatedDateTime, JobStatus status) + { + CreatedDateTime = createdDateTime; + LastUpdatedDateTime = lastUpdatedDateTime; + Status = status; + Errors = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The creation date time of the job. + /// The expiration date time of the job. + /// The job ID. + /// The last date time the job was updated. + /// Job Status. + /// The errors encountered while executing the job. + /// Keeps track of any properties unknown to the library. + internal QuestionAnsweringAuthoringProjectDeletionJobState(DateTimeOffset createdDateTime, DateTimeOffset? expirationDateTime, string jobId, DateTimeOffset lastUpdatedDateTime, JobStatus status, IReadOnlyList errors, IDictionary serializedAdditionalRawData) + { + CreatedDateTime = createdDateTime; + ExpirationDateTime = expirationDateTime; + JobId = jobId; + LastUpdatedDateTime = lastUpdatedDateTime; + Status = status; + Errors = errors; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal QuestionAnsweringAuthoringProjectDeletionJobState() + { + } + + /// The creation date time of the job. + public DateTimeOffset CreatedDateTime { get; } + /// The expiration date time of the job. + public DateTimeOffset? ExpirationDateTime { get; } + /// The job ID. + public string JobId { get; } + /// The last date time the job was updated. + public DateTimeOffset LastUpdatedDateTime { get; } + /// Job Status. + public JobStatus Status { get; } + /// The errors encountered while executing the job. + public IReadOnlyList Errors { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringProjectDeploymentJobState.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringProjectDeploymentJobState.Serialization.cs new file mode 100644 index 000000000000..07e7cee3f12d --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringProjectDeploymentJobState.Serialization.cs @@ -0,0 +1,216 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class QuestionAnsweringAuthoringProjectDeploymentJobState : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringProjectDeploymentJobState)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime, "O"); + if (Optional.IsDefined(ExpirationDateTime)) + { + writer.WritePropertyName("expirationDateTime"u8); + writer.WriteStringValue(ExpirationDateTime.Value, "O"); + } + if (options.Format != "W") + { + writer.WritePropertyName("jobId"u8); + writer.WriteStringValue(JobId); + } + writer.WritePropertyName("lastUpdatedDateTime"u8); + writer.WriteStringValue(LastUpdatedDateTime, "O"); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + if (Optional.IsCollectionDefined(Errors)) + { + writer.WritePropertyName("errors"u8); + writer.WriteStartArray(); + foreach (var item in Errors) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + QuestionAnsweringAuthoringProjectDeploymentJobState IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringProjectDeploymentJobState)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQuestionAnsweringAuthoringProjectDeploymentJobState(document.RootElement, options); + } + + internal static QuestionAnsweringAuthoringProjectDeploymentJobState DeserializeQuestionAnsweringAuthoringProjectDeploymentJobState(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset createdDateTime = default; + DateTimeOffset? expirationDateTime = default; + string jobId = default; + DateTimeOffset lastUpdatedDateTime = default; + JobStatus status = default; + IReadOnlyList errors = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("createdDateTime"u8)) + { + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("expirationDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expirationDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("jobId"u8)) + { + jobId = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastUpdatedDateTime"u8)) + { + lastUpdatedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new JobStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("errors"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Error.DeserializeError(item, options)); + } + errors = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new QuestionAnsweringAuthoringProjectDeploymentJobState( + createdDateTime, + expirationDateTime, + jobId, + lastUpdatedDateTime, + status, + errors ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringProjectDeploymentJobState)} does not support writing '{options.Format}' format."); + } + } + + QuestionAnsweringAuthoringProjectDeploymentJobState IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQuestionAnsweringAuthoringProjectDeploymentJobState(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringProjectDeploymentJobState)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static QuestionAnsweringAuthoringProjectDeploymentJobState FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQuestionAnsweringAuthoringProjectDeploymentJobState(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringProjectDeploymentJobState.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringProjectDeploymentJobState.cs new file mode 100644 index 000000000000..c2c9d3a34cb9 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringProjectDeploymentJobState.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Job state represents the job metadata and any errors. + public partial class QuestionAnsweringAuthoringProjectDeploymentJobState + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The creation date time of the job. + /// The last date time the job was updated. + /// Job Status. + internal QuestionAnsweringAuthoringProjectDeploymentJobState(DateTimeOffset createdDateTime, DateTimeOffset lastUpdatedDateTime, JobStatus status) + { + CreatedDateTime = createdDateTime; + LastUpdatedDateTime = lastUpdatedDateTime; + Status = status; + Errors = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The creation date time of the job. + /// The expiration date time of the job. + /// The job ID. + /// The last date time the job was updated. + /// Job Status. + /// The errors encountered while executing the job. + /// Keeps track of any properties unknown to the library. + internal QuestionAnsweringAuthoringProjectDeploymentJobState(DateTimeOffset createdDateTime, DateTimeOffset? expirationDateTime, string jobId, DateTimeOffset lastUpdatedDateTime, JobStatus status, IReadOnlyList errors, IDictionary serializedAdditionalRawData) + { + CreatedDateTime = createdDateTime; + ExpirationDateTime = expirationDateTime; + JobId = jobId; + LastUpdatedDateTime = lastUpdatedDateTime; + Status = status; + Errors = errors; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal QuestionAnsweringAuthoringProjectDeploymentJobState() + { + } + + /// The creation date time of the job. + public DateTimeOffset CreatedDateTime { get; } + /// The expiration date time of the job. + public DateTimeOffset? ExpirationDateTime { get; } + /// The job ID. + public string JobId { get; } + /// The last date time the job was updated. + public DateTimeOffset LastUpdatedDateTime { get; } + /// Job Status. + public JobStatus Status { get; } + /// The errors encountered while executing the job. + public IReadOnlyList Errors { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringUpdateQnasJobState.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringUpdateQnasJobState.Serialization.cs new file mode 100644 index 000000000000..4a8c7f5e66f6 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringUpdateQnasJobState.Serialization.cs @@ -0,0 +1,216 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class QuestionAnsweringAuthoringUpdateQnasJobState : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringUpdateQnasJobState)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime, "O"); + if (Optional.IsDefined(ExpirationDateTime)) + { + writer.WritePropertyName("expirationDateTime"u8); + writer.WriteStringValue(ExpirationDateTime.Value, "O"); + } + if (options.Format != "W") + { + writer.WritePropertyName("jobId"u8); + writer.WriteStringValue(JobId); + } + writer.WritePropertyName("lastUpdatedDateTime"u8); + writer.WriteStringValue(LastUpdatedDateTime, "O"); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + if (Optional.IsCollectionDefined(Errors)) + { + writer.WritePropertyName("errors"u8); + writer.WriteStartArray(); + foreach (var item in Errors) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + QuestionAnsweringAuthoringUpdateQnasJobState IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringUpdateQnasJobState)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQuestionAnsweringAuthoringUpdateQnasJobState(document.RootElement, options); + } + + internal static QuestionAnsweringAuthoringUpdateQnasJobState DeserializeQuestionAnsweringAuthoringUpdateQnasJobState(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset createdDateTime = default; + DateTimeOffset? expirationDateTime = default; + string jobId = default; + DateTimeOffset lastUpdatedDateTime = default; + JobStatus status = default; + IReadOnlyList errors = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("createdDateTime"u8)) + { + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("expirationDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expirationDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("jobId"u8)) + { + jobId = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastUpdatedDateTime"u8)) + { + lastUpdatedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new JobStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("errors"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Error.DeserializeError(item, options)); + } + errors = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new QuestionAnsweringAuthoringUpdateQnasJobState( + createdDateTime, + expirationDateTime, + jobId, + lastUpdatedDateTime, + status, + errors ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringUpdateQnasJobState)} does not support writing '{options.Format}' format."); + } + } + + QuestionAnsweringAuthoringUpdateQnasJobState IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQuestionAnsweringAuthoringUpdateQnasJobState(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringUpdateQnasJobState)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static QuestionAnsweringAuthoringUpdateQnasJobState FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQuestionAnsweringAuthoringUpdateQnasJobState(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringUpdateQnasJobState.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringUpdateQnasJobState.cs new file mode 100644 index 000000000000..29c1ebe9b3b9 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringUpdateQnasJobState.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Job state represents the job metadata and any errors. + public partial class QuestionAnsweringAuthoringUpdateQnasJobState + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The creation date time of the job. + /// The last date time the job was updated. + /// Job Status. + internal QuestionAnsweringAuthoringUpdateQnasJobState(DateTimeOffset createdDateTime, DateTimeOffset lastUpdatedDateTime, JobStatus status) + { + CreatedDateTime = createdDateTime; + LastUpdatedDateTime = lastUpdatedDateTime; + Status = status; + Errors = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The creation date time of the job. + /// The expiration date time of the job. + /// The job ID. + /// The last date time the job was updated. + /// Job Status. + /// The errors encountered while executing the job. + /// Keeps track of any properties unknown to the library. + internal QuestionAnsweringAuthoringUpdateQnasJobState(DateTimeOffset createdDateTime, DateTimeOffset? expirationDateTime, string jobId, DateTimeOffset lastUpdatedDateTime, JobStatus status, IReadOnlyList errors, IDictionary serializedAdditionalRawData) + { + CreatedDateTime = createdDateTime; + ExpirationDateTime = expirationDateTime; + JobId = jobId; + LastUpdatedDateTime = lastUpdatedDateTime; + Status = status; + Errors = errors; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal QuestionAnsweringAuthoringUpdateQnasJobState() + { + } + + /// The creation date time of the job. + public DateTimeOffset CreatedDateTime { get; } + /// The expiration date time of the job. + public DateTimeOffset? ExpirationDateTime { get; } + /// The job ID. + public string JobId { get; } + /// The last date time the job was updated. + public DateTimeOffset LastUpdatedDateTime { get; } + /// Job Status. + public JobStatus Status { get; } + /// The errors encountered while executing the job. + public IReadOnlyList Errors { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringUpdateSourcesJobState.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringUpdateSourcesJobState.Serialization.cs new file mode 100644 index 000000000000..85ff0cea50c1 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringUpdateSourcesJobState.Serialization.cs @@ -0,0 +1,216 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class QuestionAnsweringAuthoringUpdateSourcesJobState : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringUpdateSourcesJobState)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime, "O"); + if (Optional.IsDefined(ExpirationDateTime)) + { + writer.WritePropertyName("expirationDateTime"u8); + writer.WriteStringValue(ExpirationDateTime.Value, "O"); + } + if (options.Format != "W") + { + writer.WritePropertyName("jobId"u8); + writer.WriteStringValue(JobId); + } + writer.WritePropertyName("lastUpdatedDateTime"u8); + writer.WriteStringValue(LastUpdatedDateTime, "O"); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + if (Optional.IsCollectionDefined(Errors)) + { + writer.WritePropertyName("errors"u8); + writer.WriteStartArray(); + foreach (var item in Errors) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + QuestionAnsweringAuthoringUpdateSourcesJobState IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringUpdateSourcesJobState)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQuestionAnsweringAuthoringUpdateSourcesJobState(document.RootElement, options); + } + + internal static QuestionAnsweringAuthoringUpdateSourcesJobState DeserializeQuestionAnsweringAuthoringUpdateSourcesJobState(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset createdDateTime = default; + DateTimeOffset? expirationDateTime = default; + string jobId = default; + DateTimeOffset lastUpdatedDateTime = default; + JobStatus status = default; + IReadOnlyList errors = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("createdDateTime"u8)) + { + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("expirationDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expirationDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("jobId"u8)) + { + jobId = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastUpdatedDateTime"u8)) + { + lastUpdatedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new JobStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("errors"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Error.DeserializeError(item, options)); + } + errors = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new QuestionAnsweringAuthoringUpdateSourcesJobState( + createdDateTime, + expirationDateTime, + jobId, + lastUpdatedDateTime, + status, + errors ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringUpdateSourcesJobState)} does not support writing '{options.Format}' format."); + } + } + + QuestionAnsweringAuthoringUpdateSourcesJobState IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQuestionAnsweringAuthoringUpdateSourcesJobState(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QuestionAnsweringAuthoringUpdateSourcesJobState)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static QuestionAnsweringAuthoringUpdateSourcesJobState FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQuestionAnsweringAuthoringUpdateSourcesJobState(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringUpdateSourcesJobState.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringUpdateSourcesJobState.cs new file mode 100644 index 000000000000..2d1917c645ec --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringAuthoringUpdateSourcesJobState.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Job state represents the job metadata and any errors. + public partial class QuestionAnsweringAuthoringUpdateSourcesJobState + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The creation date time of the job. + /// The last date time the job was updated. + /// Job Status. + internal QuestionAnsweringAuthoringUpdateSourcesJobState(DateTimeOffset createdDateTime, DateTimeOffset lastUpdatedDateTime, JobStatus status) + { + CreatedDateTime = createdDateTime; + LastUpdatedDateTime = lastUpdatedDateTime; + Status = status; + Errors = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The creation date time of the job. + /// The expiration date time of the job. + /// The job ID. + /// The last date time the job was updated. + /// Job Status. + /// The errors encountered while executing the job. + /// Keeps track of any properties unknown to the library. + internal QuestionAnsweringAuthoringUpdateSourcesJobState(DateTimeOffset createdDateTime, DateTimeOffset? expirationDateTime, string jobId, DateTimeOffset lastUpdatedDateTime, JobStatus status, IReadOnlyList errors, IDictionary serializedAdditionalRawData) + { + CreatedDateTime = createdDateTime; + ExpirationDateTime = expirationDateTime; + JobId = jobId; + LastUpdatedDateTime = lastUpdatedDateTime; + Status = status; + Errors = errors; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal QuestionAnsweringAuthoringUpdateSourcesJobState() + { + } + + /// The creation date time of the job. + public DateTimeOffset CreatedDateTime { get; } + /// The expiration date time of the job. + public DateTimeOffset? ExpirationDateTime { get; } + /// The job ID. + public string JobId { get; } + /// The last date time the job was updated. + public DateTimeOffset LastUpdatedDateTime { get; } + /// Job Status. + public JobStatus Status { get; } + /// The errors encountered while executing the job. + public IReadOnlyList Errors { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnsweringAuthoringClient.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringProjects.cs similarity index 54% rename from sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnsweringAuthoringClient.cs rename to sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringProjects.cs index 7f1b5b712e73..148c4586354b 100644 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnsweringAuthoringClient.cs +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/QuestionAnsweringProjects.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Threading; using System.Threading.Tasks; using Autorest.CSharp.Core; using Azure.Core; @@ -13,12 +14,14 @@ namespace Azure.AI.Language.QuestionAnswering.Authoring { - // Data plane generated client. - /// The QuestionAnsweringAuthoring service client. - public partial class QuestionAnsweringAuthoringClient + // Data plane generated sub-client. + /// The QuestionAnsweringProjects sub-client. + public partial class QuestionAnsweringProjects { private const string AuthorizationHeader = "Ocp-Apim-Subscription-Key"; private readonly AzureKeyCredential _keyCredential; + private static readonly string[] AuthorizationScopes = new string[] { "https://cognitiveservices.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; @@ -29,35 +32,56 @@ public partial class QuestionAnsweringAuthoringClient /// The HTTP pipeline for sending and receiving REST requests and responses. public virtual HttpPipeline Pipeline => _pipeline; - /// Initializes a new instance of QuestionAnsweringAuthoringClient for mocking. - protected QuestionAnsweringAuthoringClient() + /// Initializes a new instance of QuestionAnsweringProjects for mocking. + protected QuestionAnsweringProjects() { } - /// Initializes a new instance of QuestionAnsweringAuthoringClient. + /// Initializes a new instance of QuestionAnsweringProjects. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// The token credential to copy. /// Supported Cognitive Services endpoint (e.g., https://<resource-name>.api.cognitiveservices.azure.com). - /// A credential used to authenticate to an Azure Service. - /// or is null. - public QuestionAnsweringAuthoringClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new QuestionAnsweringClientOptions()) + /// The API version to use for this operation. + internal QuestionAnsweringProjects(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint, string apiVersion) { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; } - /// Initializes a new instance of QuestionAnsweringAuthoringClient. - /// Supported Cognitive Services endpoint (e.g., https://<resource-name>.api.cognitiveservices.azure.com). - /// A credential used to authenticate to an Azure Service. - /// The options for configuring the client. - /// or is null. - public QuestionAnsweringAuthoringClient(Uri endpoint, AzureKeyCredential credential, QuestionAnsweringClientOptions options) - { - Argument.AssertNotNull(endpoint, nameof(endpoint)); - Argument.AssertNotNull(credential, nameof(credential)); - options ??= new QuestionAnsweringClientOptions(); - - ClientDiagnostics = new ClientDiagnostics(options, true); - _keyCredential = credential; - _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader) }, new ResponseClassifier()); - _endpoint = endpoint; - _apiVersion = options.Version; + /// Get the requested project metadata. + /// Name of the project. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetProjectDetailsAsync(string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetProjectDetailsAsync(projectName, context).ConfigureAwait(false); + return Response.FromValue(ProjectMetadata.FromResponse(response), response); + } + + /// Get the requested project metadata. + /// Name of the project. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetProjectDetails(string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetProjectDetails(projectName, context); + return Response.FromValue(ProjectMetadata.FromResponse(response), response); } /// @@ -68,20 +92,25 @@ public QuestionAnsweringAuthoringClient(Uri endpoint, AzureKeyCredential credent /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. + /// Name of the project. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// - public virtual async Task GetProjectDetailsAsync(string projectName, RequestContext context = null) + /// + public virtual async Task GetProjectDetailsAsync(string projectName, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.GetProjectDetails"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.GetProjectDetails"); scope.Start(); try { @@ -103,20 +132,25 @@ public virtual async Task GetProjectDetailsAsync(string projectName, R /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. + /// Name of the project. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// - public virtual Response GetProjectDetails(string projectName, RequestContext context = null) + /// + public virtual Response GetProjectDetails(string projectName, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.GetProjectDetails"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.GetProjectDetails"); scope.Start(); try { @@ -140,20 +174,20 @@ public virtual Response GetProjectDetails(string projectName, RequestContext con /// /// /// - /// The name of the project to use. + /// Name of the project. /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// or is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// + /// public virtual async Task CreateProjectAsync(string projectName, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.CreateProject"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.CreateProject"); scope.Start(); try { @@ -177,20 +211,20 @@ public virtual async Task CreateProjectAsync(string projectName, Reque /// /// /// - /// The name of the project to use. + /// Name of the project. /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// or is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// + /// public virtual Response CreateProject(string projectName, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.CreateProject"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.CreateProject"); scope.Start(); try { @@ -204,6 +238,36 @@ public virtual Response CreateProject(string projectName, RequestContent content } } + /// Gets the status of a Project delete job. + /// The job ID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetDeleteStatusAsync(string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetDeleteStatusAsync(jobId, context).ConfigureAwait(false); + return Response.FromValue(QuestionAnsweringAuthoringProjectDeletionJobState.FromResponse(response), response); + } + + /// Gets the status of a Project delete job. + /// The job ID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetDeleteStatus(string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetDeleteStatus(jobId, context); + return Response.FromValue(QuestionAnsweringAuthoringProjectDeletionJobState.FromResponse(response), response); + } + /// /// [Protocol Method] Gets the status of a Project delete job. /// @@ -212,20 +276,25 @@ public virtual Response CreateProject(string projectName, RequestContent content /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// Job ID. + /// The job ID. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// - public virtual async Task GetDeleteStatusAsync(string jobId, RequestContext context = null) + /// + public virtual async Task GetDeleteStatusAsync(string jobId, RequestContext context) { Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.GetDeleteStatus"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.GetDeleteStatus"); scope.Start(); try { @@ -247,20 +316,25 @@ public virtual async Task GetDeleteStatusAsync(string jobId, RequestCo /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// Job ID. + /// The job ID. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// - public virtual Response GetDeleteStatus(string jobId, RequestContext context = null) + /// + public virtual Response GetDeleteStatus(string jobId, RequestContext context) { Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.GetDeleteStatus"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.GetDeleteStatus"); scope.Start(); try { @@ -275,29 +349,75 @@ public virtual Response GetDeleteStatus(string jobId, RequestContext context = n } /// - /// [Protocol Method] Gets the status of an Export job, once job completes, returns the project metadata, and assets. + /// Gets the status of an Export job, once job completes, returns the project + /// metadata, and assets. + /// + /// Name of the project. + /// The job ID. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetExportStatusAsync(string projectName, string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetExportStatusAsync(projectName, jobId, context).ConfigureAwait(false); + return Response.FromValue(QuestionAnsweringAuthoringExportJobState.FromResponse(response), response); + } + + /// + /// Gets the status of an Export job, once job completes, returns the project + /// metadata, and assets. + /// + /// Name of the project. + /// The job ID. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response GetExportStatus(string projectName, string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetExportStatus(projectName, jobId, context); + return Response.FromValue(QuestionAnsweringAuthoringExportJobState.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets the status of an Export job, once job completes, returns the project + /// metadata, and assets. /// /// /// /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. - /// Job ID. + /// Name of the project. + /// The job ID. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// or is null. /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// - public virtual async Task GetExportStatusAsync(string projectName, string jobId, RequestContext context = null) + /// + public virtual async Task GetExportStatusAsync(string projectName, string jobId, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.GetExportStatus"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.GetExportStatus"); scope.Start(); try { @@ -312,29 +432,35 @@ public virtual async Task GetExportStatusAsync(string projectName, str } /// - /// [Protocol Method] Gets the status of an Export job, once job completes, returns the project metadata, and assets. + /// [Protocol Method] Gets the status of an Export job, once job completes, returns the project + /// metadata, and assets. /// /// /// /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. - /// Job ID. + /// Name of the project. + /// The job ID. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// or is null. /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// - public virtual Response GetExportStatus(string projectName, string jobId, RequestContext context = null) + /// + public virtual Response GetExportStatus(string projectName, string jobId, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.GetExportStatus"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.GetExportStatus"); scope.Start(); try { @@ -348,6 +474,40 @@ public virtual Response GetExportStatus(string projectName, string jobId, Reques } } + /// Gets the status of an Import job. + /// Name of the project. + /// The job ID. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetImportStatusAsync(string projectName, string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetImportStatusAsync(projectName, jobId, context).ConfigureAwait(false); + return Response.FromValue(QuestionAnsweringAuthoringImportJobState.FromResponse(response), response); + } + + /// Gets the status of an Import job. + /// Name of the project. + /// The job ID. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response GetImportStatus(string projectName, string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetImportStatus(projectName, jobId, context); + return Response.FromValue(QuestionAnsweringAuthoringImportJobState.FromResponse(response), response); + } + /// /// [Protocol Method] Gets the status of an Import job. /// @@ -356,22 +516,27 @@ public virtual Response GetExportStatus(string projectName, string jobId, Reques /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. - /// Job ID. + /// Name of the project. + /// The job ID. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// or is null. /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// - public virtual async Task GetImportStatusAsync(string projectName, string jobId, RequestContext context = null) + /// + public virtual async Task GetImportStatusAsync(string projectName, string jobId, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.GetImportStatus"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.GetImportStatus"); scope.Start(); try { @@ -393,22 +558,27 @@ public virtual async Task GetImportStatusAsync(string projectName, str /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. - /// Job ID. + /// Name of the project. + /// The job ID. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// or is null. /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// - public virtual Response GetImportStatus(string projectName, string jobId, RequestContext context = null) + /// + public virtual Response GetImportStatus(string projectName, string jobId, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.GetImportStatus"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.GetImportStatus"); scope.Start(); try { @@ -422,6 +592,44 @@ public virtual Response GetImportStatus(string projectName, string jobId, Reques } } + /// Gets the status of a Deploy job. + /// Name of the project. + /// Name of the deployment. + /// The job ID. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetDeployStatusAsync(string projectName, string deploymentName, string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetDeployStatusAsync(projectName, deploymentName, jobId, context).ConfigureAwait(false); + return Response.FromValue(QuestionAnsweringAuthoringProjectDeploymentJobState.FromResponse(response), response); + } + + /// Gets the status of a Deploy job. + /// Name of the project. + /// Name of the deployment. + /// The job ID. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + /// + public virtual Response GetDeployStatus(string projectName, string deploymentName, string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetDeployStatus(projectName, deploymentName, jobId, context); + return Response.FromValue(QuestionAnsweringAuthoringProjectDeploymentJobState.FromResponse(response), response); + } + /// /// [Protocol Method] Gets the status of a Deploy job. /// @@ -430,24 +638,29 @@ public virtual Response GetImportStatus(string projectName, string jobId, Reques /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. - /// The name of the specific deployment of the project to use. - /// Job ID. + /// Name of the project. + /// Name of the deployment. + /// The job ID. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// , or is null. /// , or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// - public virtual async Task GetDeployStatusAsync(string projectName, string deploymentName, string jobId, RequestContext context = null) + /// + public virtual async Task GetDeployStatusAsync(string projectName, string deploymentName, string jobId, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.GetDeployStatus"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.GetDeployStatus"); scope.Start(); try { @@ -469,24 +682,29 @@ public virtual async Task GetDeployStatusAsync(string projectName, str /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. - /// The name of the specific deployment of the project to use. - /// Job ID. + /// Name of the project. + /// Name of the deployment. + /// The job ID. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// , or is null. /// , or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// - public virtual Response GetDeployStatus(string projectName, string deploymentName, string jobId, RequestContext context = null) + /// + public virtual Response GetDeployStatus(string projectName, string deploymentName, string jobId, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.GetDeployStatus"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.GetDeployStatus"); scope.Start(); try { @@ -500,6 +718,42 @@ public virtual Response GetDeployStatus(string projectName, string deploymentNam } } + /// Updates all the synonyms of a project. + /// The name of the project to use. + /// All the synonyms of a project. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task UpdateSynonymsAsync(string projectName, SynonymAssets body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await UpdateSynonymsAsync(projectName, content, context).ConfigureAwait(false); + return response; + } + + /// Updates all the synonyms of a project. + /// The name of the project to use. + /// All the synonyms of a project. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response UpdateSynonyms(string projectName, SynonymAssets body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = UpdateSynonyms(projectName, content, context); + return response; + } + /// /// [Protocol Method] Updates all the synonyms of a project. /// @@ -508,6 +762,11 @@ public virtual Response GetDeployStatus(string projectName, string deploymentNam /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// /// The name of the project to use. @@ -517,13 +776,13 @@ public virtual Response GetDeployStatus(string projectName, string deploymentNam /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// + /// public virtual async Task UpdateSynonymsAsync(string projectName, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.UpdateSynonyms"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.UpdateSynonyms"); scope.Start(); try { @@ -545,6 +804,11 @@ public virtual async Task UpdateSynonymsAsync(string projectName, Requ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// /// The name of the project to use. @@ -554,13 +818,13 @@ public virtual async Task UpdateSynonymsAsync(string projectName, Requ /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// + /// public virtual Response UpdateSynonyms(string projectName, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.UpdateSynonyms"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.UpdateSynonyms"); scope.Start(); try { @@ -574,6 +838,40 @@ public virtual Response UpdateSynonyms(string projectName, RequestContent conten } } + /// Gets the status of update sources job. + /// Name of the project. + /// The job ID. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetUpdateSourcesStatusAsync(string projectName, string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetUpdateSourcesStatusAsync(projectName, jobId, context).ConfigureAwait(false); + return Response.FromValue(QuestionAnsweringAuthoringUpdateSourcesJobState.FromResponse(response), response); + } + + /// Gets the status of update sources job. + /// Name of the project. + /// The job ID. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response GetUpdateSourcesStatus(string projectName, string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetUpdateSourcesStatus(projectName, jobId, context); + return Response.FromValue(QuestionAnsweringAuthoringUpdateSourcesJobState.FromResponse(response), response); + } + /// /// [Protocol Method] Gets the status of update sources job. /// @@ -582,22 +880,27 @@ public virtual Response UpdateSynonyms(string projectName, RequestContent conten /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. - /// Job ID. + /// Name of the project. + /// The job ID. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// or is null. /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// - public virtual async Task GetUpdateSourcesStatusAsync(string projectName, string jobId, RequestContext context = null) + /// + public virtual async Task GetUpdateSourcesStatusAsync(string projectName, string jobId, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.GetUpdateSourcesStatus"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.GetUpdateSourcesStatus"); scope.Start(); try { @@ -619,22 +922,27 @@ public virtual async Task GetUpdateSourcesStatusAsync(string projectNa /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. - /// Job ID. + /// Name of the project. + /// The job ID. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// or is null. /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// - public virtual Response GetUpdateSourcesStatus(string projectName, string jobId, RequestContext context = null) + /// + public virtual Response GetUpdateSourcesStatus(string projectName, string jobId, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.GetUpdateSourcesStatus"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.GetUpdateSourcesStatus"); scope.Start(); try { @@ -648,6 +956,40 @@ public virtual Response GetUpdateSourcesStatus(string projectName, string jobId, } } + /// Gets the status of update QnAs job. + /// Name of the project. + /// The job ID. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetUpdateQnasStatusAsync(string projectName, string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetUpdateQnasStatusAsync(projectName, jobId, context).ConfigureAwait(false); + return Response.FromValue(QuestionAnsweringAuthoringUpdateQnasJobState.FromResponse(response), response); + } + + /// Gets the status of update QnAs job. + /// Name of the project. + /// The job ID. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response GetUpdateQnasStatus(string projectName, string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetUpdateQnasStatus(projectName, jobId, context); + return Response.FromValue(QuestionAnsweringAuthoringUpdateQnasJobState.FromResponse(response), response); + } + /// /// [Protocol Method] Gets the status of update QnAs job. /// @@ -656,22 +998,27 @@ public virtual Response GetUpdateSourcesStatus(string projectName, string jobId, /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. - /// Job ID. + /// Name of the project. + /// The job ID. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// or is null. /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// - public virtual async Task GetUpdateQnasStatusAsync(string projectName, string jobId, RequestContext context = null) + /// + public virtual async Task GetUpdateQnasStatusAsync(string projectName, string jobId, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.GetUpdateQnasStatus"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.GetUpdateQnasStatus"); scope.Start(); try { @@ -693,22 +1040,27 @@ public virtual async Task GetUpdateQnasStatusAsync(string projectName, /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. - /// Job ID. + /// Name of the project. + /// The job ID. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// or is null. /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// - public virtual Response GetUpdateQnasStatus(string projectName, string jobId, RequestContext context = null) + /// + public virtual Response GetUpdateQnasStatus(string projectName, string jobId, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.GetUpdateQnasStatus"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.GetUpdateQnasStatus"); scope.Start(); try { @@ -722,14 +1074,55 @@ public virtual Response GetUpdateQnasStatus(string projectName, string jobId, Re } } + /// Update Active Learning feedback. + /// The name of the project to use. + /// Feedback for Active Learning. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task AddFeedbackAsync(string projectName, ActiveLearningFeedback body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await AddFeedbackAsync(projectName, content, context).ConfigureAwait(false); + return response; + } + + /// Update Active Learning feedback. + /// The name of the project to use. + /// Feedback for Active Learning. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response AddFeedback(string projectName, ActiveLearningFeedback body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = AddFeedback(projectName, content, context); + return response; + } + /// - /// [Protocol Method] Add Active Learning feedback + /// [Protocol Method] Update Active Learning feedback. /// /// /// /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// /// The name of the project to use. @@ -739,13 +1132,13 @@ public virtual Response GetUpdateQnasStatus(string projectName, string jobId, Re /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// + /// public virtual async Task AddFeedbackAsync(string projectName, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.AddFeedback"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.AddFeedback"); scope.Start(); try { @@ -760,13 +1153,18 @@ public virtual async Task AddFeedbackAsync(string projectName, Request } /// - /// [Protocol Method] Add Active Learning feedback + /// [Protocol Method] Update Active Learning feedback. /// /// /// /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// /// The name of the project to use. @@ -776,13 +1174,13 @@ public virtual async Task AddFeedbackAsync(string projectName, Request /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - /// + /// public virtual Response AddFeedback(string projectName, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.AddFeedback"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.AddFeedback"); scope.Start(); try { @@ -796,6 +1194,34 @@ public virtual Response AddFeedback(string projectName, RequestContent content, } } + /// Gets all projects for a user. + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. + /// The cancellation token to use. + /// + public virtual AsyncPageable GetProjectsAsync(int? maxCount = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetProjectsRequest(maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetProjectsNextPageRequest(nextLink, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => ProjectMetadata.DeserializeProjectMetadata(e), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetProjects", "value", "nextLink", maxpagesize, context); + } + + /// Gets all projects for a user. + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. + /// The cancellation token to use. + /// + public virtual Pageable GetProjects(int? maxCount = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetProjectsRequest(maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetProjectsNextPageRequest(nextLink, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => ProjectMetadata.DeserializeProjectMetadata(e), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetProjects", "value", "nextLink", maxpagesize, context); + } + /// /// [Protocol Method] Gets all projects for a user. /// @@ -804,17 +1230,25 @@ public virtual Response AddFeedback(string projectName, RequestContent content, /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// Service returned a non-success status code. /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. - /// - public virtual AsyncPageable GetProjectsAsync(RequestContext context = null) + /// + public virtual AsyncPageable GetProjectsAsync(int? maxCount, int? skip, int? maxpagesize, RequestContext context) { - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetProjectsRequest(context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetProjectsNextPageRequest(nextLink, context); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringAuthoringClient.GetProjects", "value", "nextLink", context); + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetProjectsRequest(maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetProjectsNextPageRequest(nextLink, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetProjects", "value", "nextLink", maxpagesize, context); } /// @@ -825,17 +1259,63 @@ public virtual AsyncPageable GetProjectsAsync(RequestContext context /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// Service returned a non-success status code. /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. - /// - public virtual Pageable GetProjects(RequestContext context = null) + /// + public virtual Pageable GetProjects(int? maxCount, int? skip, int? maxpagesize, RequestContext context) { - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetProjectsRequest(context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetProjectsNextPageRequest(nextLink, context); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringAuthoringClient.GetProjects", "value", "nextLink", context); + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetProjectsRequest(maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetProjectsNextPageRequest(nextLink, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetProjects", "value", "nextLink", maxpagesize, context); + } + + /// List all deployments of a project. + /// Name of the project. + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual AsyncPageable GetDeploymentsAsync(string projectName, int? maxCount = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDeploymentsRequest(projectName, maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDeploymentsNextPageRequest(nextLink, projectName, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => ProjectDeployment.DeserializeProjectDeployment(e), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetDeployments", "value", "nextLink", maxpagesize, context); + } + + /// List all deployments of a project. + /// Name of the project. + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Pageable GetDeployments(string projectName, int? maxCount = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDeploymentsRequest(projectName, maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDeploymentsNextPageRequest(nextLink, projectName, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => ProjectDeployment.DeserializeProjectDeployment(e), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetDeployments", "value", "nextLink", maxpagesize, context); } /// @@ -846,22 +1326,30 @@ public virtual Pageable GetProjects(RequestContext context = null) /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. + /// Name of the project. + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. - /// - public virtual AsyncPageable GetDeploymentsAsync(string projectName, RequestContext context = null) + /// + public virtual AsyncPageable GetDeploymentsAsync(string projectName, int? maxCount, int? skip, int? maxpagesize, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDeploymentsRequest(projectName, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDeploymentsNextPageRequest(nextLink, projectName, context); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringAuthoringClient.GetDeployments", "value", "nextLink", context); + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDeploymentsRequest(projectName, maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDeploymentsNextPageRequest(nextLink, projectName, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetDeployments", "value", "nextLink", maxpagesize, context); } /// @@ -872,22 +1360,68 @@ public virtual AsyncPageable GetDeploymentsAsync(string projectName, /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. + /// Name of the project. + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. - /// - public virtual Pageable GetDeployments(string projectName, RequestContext context = null) + /// + public virtual Pageable GetDeployments(string projectName, int? maxCount, int? skip, int? maxpagesize, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDeploymentsRequest(projectName, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDeploymentsNextPageRequest(nextLink, projectName, context); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringAuthoringClient.GetDeployments", "value", "nextLink", context); + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDeploymentsRequest(projectName, maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDeploymentsNextPageRequest(nextLink, projectName, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetDeployments", "value", "nextLink", maxpagesize, context); + } + + /// Gets all the synonyms of a project. + /// Name of the project. + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual AsyncPageable GetSynonymsAsync(string projectName, int? maxCount = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSynonymsRequest(projectName, maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSynonymsNextPageRequest(nextLink, projectName, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => WordAlterations.DeserializeWordAlterations(e), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetSynonyms", "value", "nextLink", maxpagesize, context); + } + + /// Gets all the synonyms of a project. + /// Name of the project. + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Pageable GetSynonyms(string projectName, int? maxCount = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSynonymsRequest(projectName, maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSynonymsNextPageRequest(nextLink, projectName, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => WordAlterations.DeserializeWordAlterations(e), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetSynonyms", "value", "nextLink", maxpagesize, context); } /// @@ -898,22 +1432,30 @@ public virtual Pageable GetDeployments(string projectName, RequestCo /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. + /// Name of the project. + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. - /// - public virtual AsyncPageable GetSynonymsAsync(string projectName, RequestContext context = null) + /// + public virtual AsyncPageable GetSynonymsAsync(string projectName, int? maxCount, int? skip, int? maxpagesize, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSynonymsRequest(projectName, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSynonymsNextPageRequest(nextLink, projectName, context); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringAuthoringClient.GetSynonyms", "value", "nextLink", context); + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSynonymsRequest(projectName, maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSynonymsNextPageRequest(nextLink, projectName, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetSynonyms", "value", "nextLink", maxpagesize, context); } /// @@ -924,22 +1466,68 @@ public virtual AsyncPageable GetSynonymsAsync(string projectName, Re /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. + /// Name of the project. + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. - /// - public virtual Pageable GetSynonyms(string projectName, RequestContext context = null) + /// + public virtual Pageable GetSynonyms(string projectName, int? maxCount, int? skip, int? maxpagesize, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSynonymsRequest(projectName, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSynonymsNextPageRequest(nextLink, projectName, context); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringAuthoringClient.GetSynonyms", "value", "nextLink", context); + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSynonymsRequest(projectName, maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSynonymsNextPageRequest(nextLink, projectName, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetSynonyms", "value", "nextLink", maxpagesize, context); + } + + /// Gets all the sources of a project. + /// Name of the project. + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual AsyncPageable GetSourcesAsync(string projectName, int? maxCount = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSourcesRequest(projectName, maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSourcesNextPageRequest(nextLink, projectName, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => QnaSourceRecord.DeserializeQnaSourceRecord(e), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetSources", "value", "nextLink", maxpagesize, context); + } + + /// Gets all the sources of a project. + /// Name of the project. + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Pageable GetSources(string projectName, int? maxCount = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSourcesRequest(projectName, maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSourcesNextPageRequest(nextLink, projectName, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => QnaSourceRecord.DeserializeQnaSourceRecord(e), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetSources", "value", "nextLink", maxpagesize, context); } /// @@ -950,22 +1538,30 @@ public virtual Pageable GetSynonyms(string projectName, RequestConte /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. + /// Name of the project. + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. - /// - public virtual AsyncPageable GetSourcesAsync(string projectName, RequestContext context = null) + /// + public virtual AsyncPageable GetSourcesAsync(string projectName, int? maxCount, int? skip, int? maxpagesize, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSourcesRequest(projectName, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSourcesNextPageRequest(nextLink, projectName, context); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringAuthoringClient.GetSources", "value", "nextLink", context); + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSourcesRequest(projectName, maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSourcesNextPageRequest(nextLink, projectName, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetSources", "value", "nextLink", maxpagesize, context); } /// @@ -976,22 +1572,70 @@ public virtual AsyncPageable GetSourcesAsync(string projectName, Req /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. + /// Name of the project. + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. - /// - public virtual Pageable GetSources(string projectName, RequestContext context = null) + /// + public virtual Pageable GetSources(string projectName, int? maxCount, int? skip, int? maxpagesize, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSourcesRequest(projectName, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSourcesNextPageRequest(nextLink, projectName, context); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringAuthoringClient.GetSources", "value", "nextLink", context); + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSourcesRequest(projectName, maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSourcesNextPageRequest(nextLink, projectName, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetSources", "value", "nextLink", maxpagesize, context); + } + + /// Gets all the QnAs of a project. + /// Name of the project. + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. + /// Source of the QnA. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual AsyncPageable GetQnasAsync(string projectName, int? maxCount = null, int? skip = null, int? maxpagesize = null, string source = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetQnasRequest(projectName, maxCount, skip, pageSizeHint, source, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetQnasNextPageRequest(nextLink, projectName, maxCount, skip, pageSizeHint, source, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => RetrieveQnaRecord.DeserializeRetrieveQnaRecord(e), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetQnas", "value", "nextLink", maxpagesize, context); + } + + /// Gets all the QnAs of a project. + /// Name of the project. + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. + /// Source of the QnA. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Pageable GetQnas(string projectName, int? maxCount = null, int? skip = null, int? maxpagesize = null, string source = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetQnasRequest(projectName, maxCount, skip, pageSizeHint, source, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetQnasNextPageRequest(nextLink, projectName, maxCount, skip, pageSizeHint, source, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => RetrieveQnaRecord.DeserializeRetrieveQnaRecord(e), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetQnas", "value", "nextLink", maxpagesize, context); } /// @@ -1002,23 +1646,31 @@ public virtual Pageable GetSources(string projectName, RequestContex /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. + /// Name of the project. + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. /// Source of the QnA. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. - /// - public virtual AsyncPageable GetQnasAsync(string projectName, string source = null, RequestContext context = null) + /// + public virtual AsyncPageable GetQnasAsync(string projectName, int? maxCount, int? skip, int? maxpagesize, string source, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetQnasRequest(projectName, source, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetQnasNextPageRequest(nextLink, projectName, source, context); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringAuthoringClient.GetQnas", "value", "nextLink", context); + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetQnasRequest(projectName, maxCount, skip, pageSizeHint, source, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetQnasNextPageRequest(nextLink, projectName, maxCount, skip, pageSizeHint, source, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetQnas", "value", "nextLink", maxpagesize, context); } /// @@ -1029,25 +1681,34 @@ public virtual AsyncPageable GetQnasAsync(string projectName, string /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The name of the project to use. + /// Name of the project. + /// The maximum number of resources to return from the collection. + /// An offset into the collection of the first resource to be returned. + /// The maximum number of resources to include in a single response. /// Source of the QnA. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. - /// - public virtual Pageable GetQnas(string projectName, string source = null, RequestContext context = null) + /// + public virtual Pageable GetQnas(string projectName, int? maxCount, int? skip, int? maxpagesize, string source, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetQnasRequest(projectName, source, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetQnasNextPageRequest(nextLink, projectName, source, context); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringAuthoringClient.GetQnas", "value", "nextLink", context); + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetQnasRequest(projectName, maxCount, skip, pageSizeHint, source, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetQnasNextPageRequest(nextLink, projectName, maxCount, skip, pageSizeHint, source, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "QuestionAnsweringProjects.GetQnas", "value", "nextLink", maxpagesize, context); } + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method /// /// [Protocol Method] Delete the project. /// @@ -1065,17 +1726,17 @@ public virtual Pageable GetQnas(string projectName, string source = /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The representing an asynchronous operation on the service. - /// + /// public virtual async Task DeleteProjectAsync(WaitUntil waitUntil, string projectName, RequestContext context = null) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.DeleteProject"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.DeleteProject"); scope.Start(); try { using HttpMessage message = CreateDeleteProjectRequest(projectName, context); - return await ProtocolOperationHelpers.ProcessMessageWithoutResponseValueAsync(_pipeline, message, ClientDiagnostics, "QuestionAnsweringAuthoringClient.DeleteProject", OperationFinalStateVia.Location, context, waitUntil).ConfigureAwait(false); + return await ProtocolOperationHelpers.ProcessMessageWithoutResponseValueAsync(_pipeline, message, ClientDiagnostics, "QuestionAnsweringProjects.DeleteProject", OperationFinalStateVia.OperationLocation, context, waitUntil).ConfigureAwait(false); } catch (Exception e) { @@ -1084,6 +1745,7 @@ public virtual async Task DeleteProjectAsync(WaitUntil waitUntil, str } } + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method /// /// [Protocol Method] Delete the project. /// @@ -1101,17 +1763,17 @@ public virtual async Task DeleteProjectAsync(WaitUntil waitUntil, str /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The representing an asynchronous operation on the service. - /// + /// public virtual Operation DeleteProject(WaitUntil waitUntil, string projectName, RequestContext context = null) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.DeleteProject"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.DeleteProject"); scope.Start(); try { using HttpMessage message = CreateDeleteProjectRequest(projectName, context); - return ProtocolOperationHelpers.ProcessMessageWithoutResponseValue(_pipeline, message, ClientDiagnostics, "QuestionAnsweringAuthoringClient.DeleteProject", OperationFinalStateVia.Location, context, waitUntil); + return ProtocolOperationHelpers.ProcessMessageWithoutResponseValue(_pipeline, message, ClientDiagnostics, "QuestionAnsweringProjects.DeleteProject", OperationFinalStateVia.OperationLocation, context, waitUntil); } catch (Exception e) { @@ -1120,6 +1782,40 @@ public virtual Operation DeleteProject(WaitUntil waitUntil, string projectName, } } + /// Export project metadata and assets. + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the project to use. + /// Knowledge base Import or Export format. + /// Kind of the asset of the project. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task ExportAsync(WaitUntil waitUntil, string projectName, ImportExportFormat? format = null, AssestKind? assetKind = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + RequestContext context = FromCancellationToken(cancellationToken); + return await ExportAsync(waitUntil, projectName, format?.ToString(), assetKind?.ToString(), context).ConfigureAwait(false); + } + + /// Export project metadata and assets. + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the project to use. + /// Knowledge base Import or Export format. + /// Kind of the asset of the project. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Operation Export(WaitUntil waitUntil, string projectName, ImportExportFormat? format = null, AssestKind? assetKind = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + RequestContext context = FromCancellationToken(cancellationToken); + return Export(waitUntil, projectName, format?.ToString(), assetKind?.ToString(), context); + } + /// /// [Protocol Method] Export project metadata and assets. /// @@ -1128,6 +1824,11 @@ public virtual Operation DeleteProject(WaitUntil waitUntil, string projectName, /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. @@ -1139,17 +1840,17 @@ public virtual Operation DeleteProject(WaitUntil waitUntil, string projectName, /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The representing an asynchronous operation on the service. - /// - public virtual async Task> ExportAsync(WaitUntil waitUntil, string projectName, string format = null, string assetKind = null, RequestContext context = null) + /// + public virtual async Task ExportAsync(WaitUntil waitUntil, string projectName, string format, string assetKind, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.Export"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.Export"); scope.Start(); try { using HttpMessage message = CreateExportRequest(projectName, format, assetKind, context); - return await ProtocolOperationHelpers.ProcessMessageAsync(_pipeline, message, ClientDiagnostics, "QuestionAnsweringAuthoringClient.Export", OperationFinalStateVia.Location, context, waitUntil).ConfigureAwait(false); + return await ProtocolOperationHelpers.ProcessMessageWithoutResponseValueAsync(_pipeline, message, ClientDiagnostics, "QuestionAnsweringProjects.Export", OperationFinalStateVia.OperationLocation, context, waitUntil).ConfigureAwait(false); } catch (Exception e) { @@ -1166,6 +1867,11 @@ public virtual async Task> ExportAsync(WaitUntil waitUntil /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. @@ -1177,17 +1883,17 @@ public virtual async Task> ExportAsync(WaitUntil waitUntil /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The representing an asynchronous operation on the service. - /// - public virtual Operation Export(WaitUntil waitUntil, string projectName, string format = null, string assetKind = null, RequestContext context = null) + /// + public virtual Operation Export(WaitUntil waitUntil, string projectName, string format, string assetKind, RequestContext context) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.Export"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.Export"); scope.Start(); try { using HttpMessage message = CreateExportRequest(projectName, format, assetKind, context); - return ProtocolOperationHelpers.ProcessMessage(_pipeline, message, ClientDiagnostics, "QuestionAnsweringAuthoringClient.Export", OperationFinalStateVia.Location, context, waitUntil); + return ProtocolOperationHelpers.ProcessMessageWithoutResponseValue(_pipeline, message, ClientDiagnostics, "QuestionAnsweringProjects.Export", OperationFinalStateVia.OperationLocation, context, waitUntil); } catch (Exception e) { @@ -1196,6 +1902,44 @@ public virtual Operation Export(WaitUntil waitUntil, string projectN } } + /// Import project assets. + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the project to use. + /// Project assets the needs to be imported. + /// Knowledge base Import or Export format. + /// Kind of the asset of the project. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task ImportAsync(WaitUntil waitUntil, string projectName, ImportJobOptions body = null, ImportExportFormat? format = null, AssestKind? assetKind = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + using RequestContent content = body?.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + return await ImportAsync(waitUntil, projectName, content, format?.ToString(), assetKind?.ToString(), context).ConfigureAwait(false); + } + + /// Import project assets. + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the project to use. + /// Project assets the needs to be imported. + /// Knowledge base Import or Export format. + /// Kind of the asset of the project. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Operation Import(WaitUntil waitUntil, string projectName, ImportJobOptions body = null, ImportExportFormat? format = null, AssestKind? assetKind = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + using RequestContent content = body?.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + return Import(waitUntil, projectName, content, format?.ToString(), assetKind?.ToString(), context); + } + /// /// [Protocol Method] Import project assets. /// @@ -1204,6 +1948,11 @@ public virtual Operation Export(WaitUntil waitUntil, string projectN /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. @@ -1216,17 +1965,17 @@ public virtual Operation Export(WaitUntil waitUntil, string projectN /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The representing an asynchronous operation on the service. - /// - public virtual async Task> ImportAsync(WaitUntil waitUntil, string projectName, RequestContent content, string format = null, string assetKind = null, RequestContext context = null) + /// + public virtual async Task ImportAsync(WaitUntil waitUntil, string projectName, RequestContent content, string format = null, string assetKind = null, RequestContext context = null) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.Import"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.Import"); scope.Start(); try { using HttpMessage message = CreateImportRequest(projectName, content, format, assetKind, context); - return await ProtocolOperationHelpers.ProcessMessageAsync(_pipeline, message, ClientDiagnostics, "QuestionAnsweringAuthoringClient.Import", OperationFinalStateVia.Location, context, waitUntil).ConfigureAwait(false); + return await ProtocolOperationHelpers.ProcessMessageWithoutResponseValueAsync(_pipeline, message, ClientDiagnostics, "QuestionAnsweringProjects.Import", OperationFinalStateVia.OperationLocation, context, waitUntil).ConfigureAwait(false); } catch (Exception e) { @@ -1243,6 +1992,11 @@ public virtual async Task> ImportAsync(WaitUntil waitUntil /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. @@ -1255,17 +2009,17 @@ public virtual async Task> ImportAsync(WaitUntil waitUntil /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The representing an asynchronous operation on the service. - /// - public virtual Operation Import(WaitUntil waitUntil, string projectName, RequestContent content, string format = null, string assetKind = null, RequestContext context = null) + /// + public virtual Operation Import(WaitUntil waitUntil, string projectName, RequestContent content, string format = null, string assetKind = null, RequestContext context = null) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.Import"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.Import"); scope.Start(); try { using HttpMessage message = CreateImportRequest(projectName, content, format, assetKind, context); - return ProtocolOperationHelpers.ProcessMessage(_pipeline, message, ClientDiagnostics, "QuestionAnsweringAuthoringClient.Import", OperationFinalStateVia.Location, context, waitUntil); + return ProtocolOperationHelpers.ProcessMessageWithoutResponseValue(_pipeline, message, ClientDiagnostics, "QuestionAnsweringProjects.Import", OperationFinalStateVia.OperationLocation, context, waitUntil); } catch (Exception e) { @@ -1274,6 +2028,7 @@ public virtual Operation Import(WaitUntil waitUntil, string projectN } } + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method /// /// [Protocol Method] Deploy project to production. /// @@ -1292,18 +2047,18 @@ public virtual Operation Import(WaitUntil waitUntil, string projectN /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The representing an asynchronous operation on the service. - /// - public virtual async Task> DeployProjectAsync(WaitUntil waitUntil, string projectName, string deploymentName, RequestContext context = null) + /// + public virtual async Task DeployProjectAsync(WaitUntil waitUntil, string projectName, string deploymentName, RequestContext context = null) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.DeployProject"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.DeployProject"); scope.Start(); try { using HttpMessage message = CreateDeployProjectRequest(projectName, deploymentName, context); - return await ProtocolOperationHelpers.ProcessMessageAsync(_pipeline, message, ClientDiagnostics, "QuestionAnsweringAuthoringClient.DeployProject", OperationFinalStateVia.Location, context, waitUntil).ConfigureAwait(false); + return await ProtocolOperationHelpers.ProcessMessageWithoutResponseValueAsync(_pipeline, message, ClientDiagnostics, "QuestionAnsweringProjects.DeployProject", OperationFinalStateVia.OperationLocation, context, waitUntil).ConfigureAwait(false); } catch (Exception e) { @@ -1312,6 +2067,7 @@ public virtual async Task> DeployProjectAsync(WaitUntil wa } } + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method /// /// [Protocol Method] Deploy project to production. /// @@ -1330,18 +2086,18 @@ public virtual async Task> DeployProjectAsync(WaitUntil wa /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The representing an asynchronous operation on the service. - /// - public virtual Operation DeployProject(WaitUntil waitUntil, string projectName, string deploymentName, RequestContext context = null) + /// + public virtual Operation DeployProject(WaitUntil waitUntil, string projectName, string deploymentName, RequestContext context = null) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.DeployProject"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.DeployProject"); scope.Start(); try { using HttpMessage message = CreateDeployProjectRequest(projectName, deploymentName, context); - return ProtocolOperationHelpers.ProcessMessage(_pipeline, message, ClientDiagnostics, "QuestionAnsweringAuthoringClient.DeployProject", OperationFinalStateVia.Location, context, waitUntil); + return ProtocolOperationHelpers.ProcessMessageWithoutResponseValue(_pipeline, message, ClientDiagnostics, "QuestionAnsweringProjects.DeployProject", OperationFinalStateVia.OperationLocation, context, waitUntil); } catch (Exception e) { @@ -1367,20 +2123,19 @@ public virtual Operation DeployProject(WaitUntil waitUntil, string p /// or is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. - /// The from the service that will contain a containing a list of objects once the asynchronous operation on the service has completed. Details of the body schema for the operation's final value are in the Remarks section below. - /// - public virtual async Task>> UpdateSourcesAsync(WaitUntil waitUntil, string projectName, RequestContent content, RequestContext context = null) + /// The representing an asynchronous operation on the service. + /// + public virtual async Task UpdateSourcesAsync(WaitUntil waitUntil, string projectName, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.UpdateSources"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.UpdateSources"); scope.Start(); try { - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateUpdateSourcesNextPageRequest(nextLink, projectName, content, context); using HttpMessage message = CreateUpdateSourcesRequest(projectName, content, context); - return await GeneratorPageableHelpers.CreateAsyncPageable(waitUntil, message, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, OperationFinalStateVia.Location, "QuestionAnsweringAuthoringClient.UpdateSources", "value", "nextLink", context).ConfigureAwait(false); + return await ProtocolOperationHelpers.ProcessMessageWithoutResponseValueAsync(_pipeline, message, ClientDiagnostics, "QuestionAnsweringProjects.UpdateSources", OperationFinalStateVia.OperationLocation, context, waitUntil).ConfigureAwait(false); } catch (Exception e) { @@ -1406,20 +2161,19 @@ public virtual async Task>> UpdateSourcesAsy /// or is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. - /// The from the service that will contain a containing a list of objects once the asynchronous operation on the service has completed. Details of the body schema for the operation's final value are in the Remarks section below. - /// - public virtual Operation> UpdateSources(WaitUntil waitUntil, string projectName, RequestContent content, RequestContext context = null) + /// The representing an asynchronous operation on the service. + /// + public virtual Operation UpdateSources(WaitUntil waitUntil, string projectName, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.UpdateSources"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.UpdateSources"); scope.Start(); try { - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateUpdateSourcesNextPageRequest(nextLink, projectName, content, context); using HttpMessage message = CreateUpdateSourcesRequest(projectName, content, context); - return GeneratorPageableHelpers.CreatePageable(waitUntil, message, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, OperationFinalStateVia.Location, "QuestionAnsweringAuthoringClient.UpdateSources", "value", "nextLink", context); + return ProtocolOperationHelpers.ProcessMessageWithoutResponseValue(_pipeline, message, ClientDiagnostics, "QuestionAnsweringProjects.UpdateSources", OperationFinalStateVia.OperationLocation, context, waitUntil); } catch (Exception e) { @@ -1445,20 +2199,19 @@ public virtual Operation> UpdateSources(WaitUntil waitUntil /// or is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. - /// The from the service that will contain a containing a list of objects once the asynchronous operation on the service has completed. Details of the body schema for the operation's final value are in the Remarks section below. - /// - public virtual async Task>> UpdateQnasAsync(WaitUntil waitUntil, string projectName, RequestContent content, RequestContext context = null) + /// The representing an asynchronous operation on the service. + /// + public virtual async Task UpdateQnasAsync(WaitUntil waitUntil, string projectName, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.UpdateQnas"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.UpdateQnas"); scope.Start(); try { - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateUpdateQnasNextPageRequest(nextLink, projectName, content, context); using HttpMessage message = CreateUpdateQnasRequest(projectName, content, context); - return await GeneratorPageableHelpers.CreateAsyncPageable(waitUntil, message, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, OperationFinalStateVia.Location, "QuestionAnsweringAuthoringClient.UpdateQnas", "value", "nextLink", context).ConfigureAwait(false); + return await ProtocolOperationHelpers.ProcessMessageWithoutResponseValueAsync(_pipeline, message, ClientDiagnostics, "QuestionAnsweringProjects.UpdateQnas", OperationFinalStateVia.OperationLocation, context, waitUntil).ConfigureAwait(false); } catch (Exception e) { @@ -1484,20 +2237,19 @@ public virtual async Task>> UpdateQnasAsync( /// or is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. - /// The from the service that will contain a containing a list of objects once the asynchronous operation on the service has completed. Details of the body schema for the operation's final value are in the Remarks section below. - /// - public virtual Operation> UpdateQnas(WaitUntil waitUntil, string projectName, RequestContent content, RequestContext context = null) + /// The representing an asynchronous operation on the service. + /// + public virtual Operation UpdateQnas(WaitUntil waitUntil, string projectName, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringAuthoringClient.UpdateQnas"); + using var scope = ClientDiagnostics.CreateScope("QuestionAnsweringProjects.UpdateQnas"); scope.Start(); try { - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateUpdateQnasNextPageRequest(nextLink, projectName, content, context); using HttpMessage message = CreateUpdateQnasRequest(projectName, content, context); - return GeneratorPageableHelpers.CreatePageable(waitUntil, message, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, OperationFinalStateVia.Location, "QuestionAnsweringAuthoringClient.UpdateQnas", "value", "nextLink", context); + return ProtocolOperationHelpers.ProcessMessageWithoutResponseValue(_pipeline, message, ClientDiagnostics, "QuestionAnsweringProjects.UpdateQnas", OperationFinalStateVia.OperationLocation, context, waitUntil); } catch (Exception e) { @@ -1506,7 +2258,7 @@ public virtual Operation> UpdateQnas(WaitUntil waitUntil, s } } - internal HttpMessage CreateGetProjectsRequest(RequestContext context) + internal HttpMessage CreateGetProjectsRequest(int? maxCount, int? skip, int? maxpagesize, RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); var request = message.Request; @@ -1514,8 +2266,20 @@ internal HttpMessage CreateGetProjectsRequest(RequestContext context) var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects", false); + uri.AppendPath("/authoring/query-knowledgebases/projects", false); uri.AppendQuery("api-version", _apiVersion, true); + if (maxCount != null) + { + uri.AppendQuery("top", maxCount.Value, true); + } + if (skip != null) + { + uri.AppendQuery("skip", skip.Value, true); + } + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } request.Uri = uri; request.Headers.Add("Accept", "application/json"); return message; @@ -1529,7 +2293,7 @@ internal HttpMessage CreateGetProjectDetailsRequest(string projectName, RequestC var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/", false); uri.AppendPath(projectName, true); uri.AppendQuery("api-version", _apiVersion, true); request.Uri = uri; @@ -1545,7 +2309,7 @@ internal HttpMessage CreateCreateProjectRequest(string projectName, RequestConte var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/", false); uri.AppendPath(projectName, true); uri.AppendQuery("api-version", _apiVersion, true); request.Uri = uri; @@ -1563,7 +2327,7 @@ internal HttpMessage CreateDeleteProjectRequest(string projectName, RequestConte var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/", false); uri.AppendPath(projectName, true); uri.AppendQuery("api-version", _apiVersion, true); request.Uri = uri; @@ -1579,7 +2343,7 @@ internal HttpMessage CreateGetDeleteStatusRequest(string jobId, RequestContext c var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/deletion-jobs/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/deletion-jobs/", false); uri.AppendPath(jobId, true); uri.AppendQuery("api-version", _apiVersion, true); request.Uri = uri; @@ -1595,7 +2359,7 @@ internal HttpMessage CreateExportRequest(string projectName, string format, stri var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/", false); uri.AppendPath(projectName, true); uri.AppendPath("/:export", false); uri.AppendQuery("api-version", _apiVersion, true); @@ -1620,7 +2384,7 @@ internal HttpMessage CreateGetExportStatusRequest(string projectName, string job var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/", false); uri.AppendPath(projectName, true); uri.AppendPath("/export/jobs/", false); uri.AppendPath(jobId, true); @@ -1632,13 +2396,13 @@ internal HttpMessage CreateGetExportStatusRequest(string projectName, string job internal HttpMessage CreateImportRequest(string projectName, RequestContent content, string format, string assetKind, RequestContext context) { - var message = _pipeline.CreateMessage(context, ResponseClassifier200202); + var message = _pipeline.CreateMessage(context, ResponseClassifier202); var request = message.Request; request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/", false); uri.AppendPath(projectName, true); uri.AppendPath("/:import", false); uri.AppendQuery("api-version", _apiVersion, true); @@ -1665,7 +2429,7 @@ internal HttpMessage CreateGetImportStatusRequest(string projectName, string job var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/", false); uri.AppendPath(projectName, true); uri.AppendPath("/import/jobs/", false); uri.AppendPath(jobId, true); @@ -1677,13 +2441,13 @@ internal HttpMessage CreateGetImportStatusRequest(string projectName, string job internal HttpMessage CreateDeployProjectRequest(string projectName, string deploymentName, RequestContext context) { - var message = _pipeline.CreateMessage(context, ResponseClassifier200202); + var message = _pipeline.CreateMessage(context, ResponseClassifier202); var request = message.Request; request.Method = RequestMethod.Put; var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/", false); uri.AppendPath(projectName, true); uri.AppendPath("/deployments/", false); uri.AppendPath(deploymentName, true); @@ -1701,7 +2465,7 @@ internal HttpMessage CreateGetDeployStatusRequest(string projectName, string dep var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/", false); uri.AppendPath(projectName, true); uri.AppendPath("/deployments/", false); uri.AppendPath(deploymentName, true); @@ -1713,7 +2477,7 @@ internal HttpMessage CreateGetDeployStatusRequest(string projectName, string dep return message; } - internal HttpMessage CreateGetDeploymentsRequest(string projectName, RequestContext context) + internal HttpMessage CreateGetDeploymentsRequest(string projectName, int? maxCount, int? skip, int? maxpagesize, RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); var request = message.Request; @@ -1721,16 +2485,28 @@ internal HttpMessage CreateGetDeploymentsRequest(string projectName, RequestCont var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/", false); uri.AppendPath(projectName, true); uri.AppendPath("/deployments", false); uri.AppendQuery("api-version", _apiVersion, true); + if (maxCount != null) + { + uri.AppendQuery("top", maxCount.Value, true); + } + if (skip != null) + { + uri.AppendQuery("skip", skip.Value, true); + } + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } request.Uri = uri; request.Headers.Add("Accept", "application/json"); return message; } - internal HttpMessage CreateGetSynonymsRequest(string projectName, RequestContext context) + internal HttpMessage CreateGetSynonymsRequest(string projectName, int? maxCount, int? skip, int? maxpagesize, RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); var request = message.Request; @@ -1738,10 +2514,22 @@ internal HttpMessage CreateGetSynonymsRequest(string projectName, RequestContext var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/", false); uri.AppendPath(projectName, true); uri.AppendPath("/synonyms", false); uri.AppendQuery("api-version", _apiVersion, true); + if (maxCount != null) + { + uri.AppendQuery("top", maxCount.Value, true); + } + if (skip != null) + { + uri.AppendQuery("skip", skip.Value, true); + } + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } request.Uri = uri; request.Headers.Add("Accept", "application/json"); return message; @@ -1755,7 +2543,7 @@ internal HttpMessage CreateUpdateSynonymsRequest(string projectName, RequestCont var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/", false); uri.AppendPath(projectName, true); uri.AppendPath("/synonyms", false); uri.AppendQuery("api-version", _apiVersion, true); @@ -1766,7 +2554,7 @@ internal HttpMessage CreateUpdateSynonymsRequest(string projectName, RequestCont return message; } - internal HttpMessage CreateGetSourcesRequest(string projectName, RequestContext context) + internal HttpMessage CreateGetSourcesRequest(string projectName, int? maxCount, int? skip, int? maxpagesize, RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); var request = message.Request; @@ -1774,10 +2562,22 @@ internal HttpMessage CreateGetSourcesRequest(string projectName, RequestContext var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/", false); uri.AppendPath(projectName, true); uri.AppendPath("/sources", false); uri.AppendQuery("api-version", _apiVersion, true); + if (maxCount != null) + { + uri.AppendQuery("top", maxCount.Value, true); + } + if (skip != null) + { + uri.AppendQuery("skip", skip.Value, true); + } + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } request.Uri = uri; request.Headers.Add("Accept", "application/json"); return message; @@ -1785,13 +2585,13 @@ internal HttpMessage CreateGetSourcesRequest(string projectName, RequestContext internal HttpMessage CreateUpdateSourcesRequest(string projectName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(context, ResponseClassifier200202); + var message = _pipeline.CreateMessage(context, ResponseClassifier202); var request = message.Request; request.Method = RequestMethod.Patch; var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/", false); uri.AppendPath(projectName, true); uri.AppendPath("/sources", false); uri.AppendQuery("api-version", _apiVersion, true); @@ -1810,7 +2610,7 @@ internal HttpMessage CreateGetUpdateSourcesStatusRequest(string projectName, str var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/", false); uri.AppendPath(projectName, true); uri.AppendPath("/sources/jobs/", false); uri.AppendPath(jobId, true); @@ -1820,7 +2620,7 @@ internal HttpMessage CreateGetUpdateSourcesStatusRequest(string projectName, str return message; } - internal HttpMessage CreateGetQnasRequest(string projectName, string source, RequestContext context) + internal HttpMessage CreateGetQnasRequest(string projectName, int? maxCount, int? skip, int? maxpagesize, string source, RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); var request = message.Request; @@ -1828,10 +2628,22 @@ internal HttpMessage CreateGetQnasRequest(string projectName, string source, Req var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/", false); uri.AppendPath(projectName, true); uri.AppendPath("/qnas", false); uri.AppendQuery("api-version", _apiVersion, true); + if (maxCount != null) + { + uri.AppendQuery("top", maxCount.Value, true); + } + if (skip != null) + { + uri.AppendQuery("skip", skip.Value, true); + } + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } if (source != null) { uri.AppendQuery("source", source, true); @@ -1843,13 +2655,13 @@ internal HttpMessage CreateGetQnasRequest(string projectName, string source, Req internal HttpMessage CreateUpdateQnasRequest(string projectName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(context, ResponseClassifier200202); + var message = _pipeline.CreateMessage(context, ResponseClassifier202); var request = message.Request; request.Method = RequestMethod.Patch; var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/", false); uri.AppendPath(projectName, true); uri.AppendPath("/qnas", false); uri.AppendQuery("api-version", _apiVersion, true); @@ -1868,7 +2680,7 @@ internal HttpMessage CreateGetUpdateQnasStatusRequest(string projectName, string var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/", false); uri.AppendPath(projectName, true); uri.AppendPath("/qnas/jobs/", false); uri.AppendPath(jobId, true); @@ -1886,7 +2698,7 @@ internal HttpMessage CreateAddFeedbackRequest(string projectName, RequestContent var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendRaw("/language", false); - uri.AppendPath("/query-knowledgebases/projects/", false); + uri.AppendPath("/authoring/query-knowledgebases/projects/", false); uri.AppendPath(projectName, true); uri.AppendPath("/feedback", false); uri.AppendQuery("api-version", _apiVersion, true); @@ -1897,7 +2709,7 @@ internal HttpMessage CreateAddFeedbackRequest(string projectName, RequestContent return message; } - internal HttpMessage CreateGetProjectsNextPageRequest(string nextLink, RequestContext context) + internal HttpMessage CreateGetProjectsNextPageRequest(string nextLink, int? maxCount, int? skip, int? maxpagesize, RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); var request = message.Request; @@ -1911,7 +2723,7 @@ internal HttpMessage CreateGetProjectsNextPageRequest(string nextLink, RequestCo return message; } - internal HttpMessage CreateGetDeploymentsNextPageRequest(string nextLink, string projectName, RequestContext context) + internal HttpMessage CreateGetDeploymentsNextPageRequest(string nextLink, string projectName, int? maxCount, int? skip, int? maxpagesize, RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); var request = message.Request; @@ -1925,7 +2737,7 @@ internal HttpMessage CreateGetDeploymentsNextPageRequest(string nextLink, string return message; } - internal HttpMessage CreateGetSynonymsNextPageRequest(string nextLink, string projectName, RequestContext context) + internal HttpMessage CreateGetSynonymsNextPageRequest(string nextLink, string projectName, int? maxCount, int? skip, int? maxpagesize, RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); var request = message.Request; @@ -1939,7 +2751,7 @@ internal HttpMessage CreateGetSynonymsNextPageRequest(string nextLink, string pr return message; } - internal HttpMessage CreateGetSourcesNextPageRequest(string nextLink, string projectName, RequestContext context) + internal HttpMessage CreateGetSourcesNextPageRequest(string nextLink, string projectName, int? maxCount, int? skip, int? maxpagesize, RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); var request = message.Request; @@ -1953,7 +2765,7 @@ internal HttpMessage CreateGetSourcesNextPageRequest(string nextLink, string pro return message; } - internal HttpMessage CreateGetQnasNextPageRequest(string nextLink, string projectName, string source, RequestContext context) + internal HttpMessage CreateGetQnasNextPageRequest(string nextLink, string projectName, int? maxCount, int? skip, int? maxpagesize, string source, RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); var request = message.Request; @@ -1967,32 +2779,15 @@ internal HttpMessage CreateGetQnasNextPageRequest(string nextLink, string projec return message; } - internal HttpMessage CreateUpdateSourcesNextPageRequest(string nextLink, string projectName, RequestContent content, RequestContext context) + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/language", false); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } - internal HttpMessage CreateUpdateQnasNextPageRequest(string nextLink, string projectName, RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/language", false); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; + return new RequestContext() { CancellationToken = cancellationToken }; } private static ResponseClassifier _responseClassifier200; diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/RetrieveQnaRecord.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/RetrieveQnaRecord.Serialization.cs new file mode 100644 index 000000000000..98d1ebd1d3be --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/RetrieveQnaRecord.Serialization.cs @@ -0,0 +1,282 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class RetrieveQnaRecord : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RetrieveQnaRecord)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteNumberValue(Id); + } + if (Optional.IsDefined(Answer)) + { + writer.WritePropertyName("answer"u8); + writer.WriteStringValue(Answer); + } + if (Optional.IsDefined(Source)) + { + writer.WritePropertyName("source"u8); + writer.WriteStringValue(Source); + } + if (Optional.IsCollectionDefined(Questions)) + { + writer.WritePropertyName("questions"u8); + writer.WriteStartArray(); + foreach (var item in Questions) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Dialog)) + { + writer.WritePropertyName("dialog"u8); + writer.WriteObjectValue(Dialog, options); + } + if (Optional.IsCollectionDefined(ActiveLearningSuggestions)) + { + writer.WritePropertyName("activeLearningSuggestions"u8); + writer.WriteStartArray(); + foreach (var item in ActiveLearningSuggestions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(LastUpdatedDateTime)) + { + writer.WritePropertyName("lastUpdatedDateTime"u8); + writer.WriteStringValue(LastUpdatedDateTime.Value, "O"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RetrieveQnaRecord IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RetrieveQnaRecord)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRetrieveQnaRecord(document.RootElement, options); + } + + internal static RetrieveQnaRecord DeserializeRetrieveQnaRecord(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int id = default; + string answer = default; + string source = default; + IReadOnlyList questions = default; + IReadOnlyDictionary metadata = default; + QnaDialog dialog = default; + IReadOnlyList activeLearningSuggestions = default; + DateTimeOffset? lastUpdatedDateTime = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("answer"u8)) + { + answer = property.Value.GetString(); + continue; + } + if (property.NameEquals("source"u8)) + { + source = property.Value.GetString(); + continue; + } + if (property.NameEquals("questions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + questions = array; + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (property.NameEquals("dialog"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dialog = QnaDialog.DeserializeQnaDialog(property.Value, options); + continue; + } + if (property.NameEquals("activeLearningSuggestions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SuggestedQuestionsCluster.DeserializeSuggestedQuestionsCluster(item, options)); + } + activeLearningSuggestions = array; + continue; + } + if (property.NameEquals("lastUpdatedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastUpdatedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RetrieveQnaRecord( + id, + answer, + source, + questions ?? new ChangeTrackingList(), + metadata ?? new ChangeTrackingDictionary(), + dialog, + activeLearningSuggestions ?? new ChangeTrackingList(), + lastUpdatedDateTime, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RetrieveQnaRecord)} does not support writing '{options.Format}' format."); + } + } + + RetrieveQnaRecord IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRetrieveQnaRecord(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RetrieveQnaRecord)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RetrieveQnaRecord FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRetrieveQnaRecord(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/RetrieveQnaRecord.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/RetrieveQnaRecord.cs new file mode 100644 index 000000000000..d35edfdc4b43 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/RetrieveQnaRecord.cs @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// QnA Record with last updated date-time. + public partial class RetrieveQnaRecord + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal RetrieveQnaRecord() + { + Questions = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + ActiveLearningSuggestions = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Unique ID for the QnA. + /// Answer text. + /// + /// Source from which QnA was indexed e.g. + /// https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs . + /// + /// List of questions associated with the answer. + /// + /// Metadata associated with the answer, useful to categorize or filter question + /// answers. + /// + /// Context of a QnA. + /// List of Active Learning suggestions for the QnA. + /// Date-time when the QnA was last updated. + /// Keeps track of any properties unknown to the library. + internal RetrieveQnaRecord(int id, string answer, string source, IReadOnlyList questions, IReadOnlyDictionary metadata, QnaDialog dialog, IReadOnlyList activeLearningSuggestions, DateTimeOffset? lastUpdatedDateTime, IDictionary serializedAdditionalRawData) + { + Id = id; + Answer = answer; + Source = source; + Questions = questions; + Metadata = metadata; + Dialog = dialog; + ActiveLearningSuggestions = activeLearningSuggestions; + LastUpdatedDateTime = lastUpdatedDateTime; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Unique ID for the QnA. + public int Id { get; } + /// Answer text. + public string Answer { get; } + /// + /// Source from which QnA was indexed e.g. + /// https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs . + /// + public string Source { get; } + /// List of questions associated with the answer. + public IReadOnlyList Questions { get; } + /// + /// Metadata associated with the answer, useful to categorize or filter question + /// answers. + /// + public IReadOnlyDictionary Metadata { get; } + /// Context of a QnA. + public QnaDialog Dialog { get; } + /// List of Active Learning suggestions for the QnA. + public IReadOnlyList ActiveLearningSuggestions { get; } + /// Date-time when the QnA was last updated. + public DateTimeOffset? LastUpdatedDateTime { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SourceContentStructureKind.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SourceContentStructureKind.cs new file mode 100644 index 000000000000..063c2e3574a3 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SourceContentStructureKind.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Content structure type for sources. + public readonly partial struct SourceContentStructureKind : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public SourceContentStructureKind(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnstructuredValue = "unstructured"; + + /// Unstructured. + public static SourceContentStructureKind Unstructured { get; } = new SourceContentStructureKind(UnstructuredValue); + /// Determines if two values are the same. + public static bool operator ==(SourceContentStructureKind left, SourceContentStructureKind right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(SourceContentStructureKind left, SourceContentStructureKind right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator SourceContentStructureKind(string value) => new SourceContentStructureKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SourceContentStructureKind other && Equals(other); + /// + public bool Equals(SourceContentStructureKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SourceKind.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SourceKind.cs new file mode 100644 index 000000000000..e0f2c5f2ab17 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SourceKind.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Supported source types. + public readonly partial struct SourceKind : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public SourceKind(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FileValue = "file"; + private const string UrlValue = "url"; + + /// File Source. + public static SourceKind File { get; } = new SourceKind(FileValue); + /// URI Source. + public static SourceKind Url { get; } = new SourceKind(UrlValue); + /// Determines if two values are the same. + public static bool operator ==(SourceKind left, SourceKind right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(SourceKind left, SourceKind right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator SourceKind(string value) => new SourceKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SourceKind other && Equals(other); + /// + public bool Equals(SourceKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SuggestedQuestion.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SuggestedQuestion.Serialization.cs new file mode 100644 index 000000000000..2192bbb785f2 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SuggestedQuestion.Serialization.cs @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class SuggestedQuestion : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SuggestedQuestion)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Question)) + { + writer.WritePropertyName("question"u8); + writer.WriteStringValue(Question); + } + if (Optional.IsDefined(UserSuggestedCount)) + { + writer.WritePropertyName("userSuggestedCount"u8); + writer.WriteNumberValue(UserSuggestedCount.Value); + } + if (Optional.IsDefined(AutoSuggestedCount)) + { + writer.WritePropertyName("autoSuggestedCount"u8); + writer.WriteNumberValue(AutoSuggestedCount.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SuggestedQuestion IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SuggestedQuestion)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSuggestedQuestion(document.RootElement, options); + } + + internal static SuggestedQuestion DeserializeSuggestedQuestion(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string question = default; + int? userSuggestedCount = default; + int? autoSuggestedCount = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("question"u8)) + { + question = property.Value.GetString(); + continue; + } + if (property.NameEquals("userSuggestedCount"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + userSuggestedCount = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("autoSuggestedCount"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + autoSuggestedCount = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SuggestedQuestion(question, userSuggestedCount, autoSuggestedCount, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SuggestedQuestion)} does not support writing '{options.Format}' format."); + } + } + + SuggestedQuestion IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSuggestedQuestion(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SuggestedQuestion)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SuggestedQuestion FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSuggestedQuestion(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SuggestedQuestion.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SuggestedQuestion.cs new file mode 100644 index 000000000000..73d28bfe814e --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SuggestedQuestion.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Question suggested by the Active Learning feature. + public partial class SuggestedQuestion + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public SuggestedQuestion() + { + } + + /// Initializes a new instance of . + /// Question suggested by the Active Learning feature. + /// The number of times the question was suggested explicitly by the user. + /// + /// The number of times the question was suggested automatically by the Active + /// Learning algorithm. + /// + /// Keeps track of any properties unknown to the library. + internal SuggestedQuestion(string question, int? userSuggestedCount, int? autoSuggestedCount, IDictionary serializedAdditionalRawData) + { + Question = question; + UserSuggestedCount = userSuggestedCount; + AutoSuggestedCount = autoSuggestedCount; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Question suggested by the Active Learning feature. + public string Question { get; set; } + /// The number of times the question was suggested explicitly by the user. + public int? UserSuggestedCount { get; set; } + /// + /// The number of times the question was suggested automatically by the Active + /// Learning algorithm. + /// + public int? AutoSuggestedCount { get; set; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SuggestedQuestionsCluster.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SuggestedQuestionsCluster.Serialization.cs new file mode 100644 index 000000000000..67f8eda21ce8 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SuggestedQuestionsCluster.Serialization.cs @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class SuggestedQuestionsCluster : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SuggestedQuestionsCluster)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ClusterHead)) + { + writer.WritePropertyName("clusterHead"u8); + writer.WriteStringValue(ClusterHead); + } + if (Optional.IsCollectionDefined(SuggestedQuestions)) + { + writer.WritePropertyName("suggestedQuestions"u8); + writer.WriteStartArray(); + foreach (var item in SuggestedQuestions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SuggestedQuestionsCluster IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SuggestedQuestionsCluster)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSuggestedQuestionsCluster(document.RootElement, options); + } + + internal static SuggestedQuestionsCluster DeserializeSuggestedQuestionsCluster(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string clusterHead = default; + IList suggestedQuestions = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("clusterHead"u8)) + { + clusterHead = property.Value.GetString(); + continue; + } + if (property.NameEquals("suggestedQuestions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SuggestedQuestion.DeserializeSuggestedQuestion(item, options)); + } + suggestedQuestions = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SuggestedQuestionsCluster(clusterHead, suggestedQuestions ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SuggestedQuestionsCluster)} does not support writing '{options.Format}' format."); + } + } + + SuggestedQuestionsCluster IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSuggestedQuestionsCluster(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SuggestedQuestionsCluster)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SuggestedQuestionsCluster FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSuggestedQuestionsCluster(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SuggestedQuestionsCluster.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SuggestedQuestionsCluster.cs new file mode 100644 index 000000000000..ef8f81c2a7e0 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SuggestedQuestionsCluster.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Active Learning suggested questions cluster details. + public partial class SuggestedQuestionsCluster + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public SuggestedQuestionsCluster() + { + SuggestedQuestions = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// Question chosen as the head of suggested questions cluster by Active Learning + /// clustering algorithm. + /// + /// List of all suggested questions for the QnA. + /// Keeps track of any properties unknown to the library. + internal SuggestedQuestionsCluster(string clusterHead, IList suggestedQuestions, IDictionary serializedAdditionalRawData) + { + ClusterHead = clusterHead; + SuggestedQuestions = suggestedQuestions; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Question chosen as the head of suggested questions cluster by Active Learning + /// clustering algorithm. + /// + public string ClusterHead { get; set; } + /// List of all suggested questions for the QnA. + public IList SuggestedQuestions { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SynonymAssets.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SynonymAssets.Serialization.cs new file mode 100644 index 000000000000..44edb60e4d7b --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SynonymAssets.Serialization.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class SynonymAssets : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SynonymAssets)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SynonymAssets IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SynonymAssets)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSynonymAssets(document.RootElement, options); + } + + internal static SynonymAssets DeserializeSynonymAssets(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(WordAlterations.DeserializeWordAlterations(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SynonymAssets(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SynonymAssets)} does not support writing '{options.Format}' format."); + } + } + + SynonymAssets IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSynonymAssets(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SynonymAssets)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SynonymAssets FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSynonymAssets(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SynonymAssets.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SynonymAssets.cs new file mode 100644 index 000000000000..9c203a5e3b72 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/SynonymAssets.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Request payload for updating synonyms. + public partial class SynonymAssets + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The WordAlterations items on this page. + /// is null. + public SynonymAssets(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The WordAlterations items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal SynonymAssets(IList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SynonymAssets() + { + } + + /// The WordAlterations items on this page. + public IList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; set; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/WordAlterations.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/WordAlterations.Serialization.cs new file mode 100644 index 000000000000..91d68aa5d079 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/WordAlterations.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + public partial class WordAlterations : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WordAlterations)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("alterations"u8); + writer.WriteStartArray(); + foreach (var item in Alterations) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + WordAlterations IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WordAlterations)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWordAlterations(document.RootElement, options); + } + + internal static WordAlterations DeserializeWordAlterations(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList alterations = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("alterations"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + alterations = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WordAlterations(alterations, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(WordAlterations)} does not support writing '{options.Format}' format."); + } + } + + WordAlterations IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWordAlterations(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WordAlterations)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static WordAlterations FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWordAlterations(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/WordAlterations.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/WordAlterations.cs new file mode 100644 index 000000000000..21df38477697 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Generated/WordAlterations.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Language.QuestionAnswering.Authoring +{ + /// Collection of word alterations. + public partial class WordAlterations + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Collection of word alterations. + /// is null. + public WordAlterations(IEnumerable alterations) + { + Argument.AssertNotNull(alterations, nameof(alterations)); + + Alterations = alterations.ToList(); + } + + /// Initializes a new instance of . + /// Collection of word alterations. + /// Keeps track of any properties unknown to the library. + internal WordAlterations(IList alterations, IDictionary serializedAdditionalRawData) + { + Alterations = alterations; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal WordAlterations() + { + } + + /// Collection of word alterations. + public IList Alterations { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Properties/AssemblyInfo.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..37fa9a6ebb07 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/src/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Azure.AI.Language.QuestionAnswering.Authoring.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] + +// Replace Microsoft.Test with the correct resource provider namepace for your service and uncomment. +// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers +// for the list of possible values. +[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Template")] diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/tests/Azure.AI.Language.QuestionAnswering.Authoring.Tests.csproj b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/tests/Azure.AI.Language.QuestionAnswering.Authoring.Tests.csproj new file mode 100644 index 000000000000..78aacc170bdf --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/tests/Azure.AI.Language.QuestionAnswering.Authoring.Tests.csproj @@ -0,0 +1,20 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + + + + + + + + + + + + + + diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/tests/Generated/Samples/Samples_QuestionAnsweringAuthoringClient.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/tests/Generated/Samples/Samples_QuestionAnsweringProjects.cs similarity index 54% rename from sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/tests/Generated/Samples/Samples_QuestionAnsweringAuthoringClient.cs rename to sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/tests/Generated/Samples/Samples_QuestionAnsweringProjects.cs index 89e9c3481f4a..23571eec0d75 100644 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/tests/Generated/Samples/Samples_QuestionAnsweringAuthoringClient.cs +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/tests/Generated/Samples/Samples_QuestionAnsweringProjects.cs @@ -8,52 +8,73 @@ using System; using System.Text.Json; using System.Threading.Tasks; -using Azure.AI.Language.QuestionAnswering.Authoring; using Azure.Core; using Azure.Identity; using NUnit.Framework; -namespace Azure.AI.Language.QuestionAnswering.Samples +namespace Azure.AI.Language.QuestionAnswering.Authoring.Samples { - public partial class Samples_QuestionAnsweringAuthoringClient + public partial class Samples_QuestionAnsweringProjects { [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetProjectDetails_ShortVersion() + public void Example_ProjectMetadata_GetProjectDetails_ShortVersion() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = client.GetProjectDetails(""); + Response response = client.GetProjectDetails("", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("projectName").ToString()); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetProjectDetails_ShortVersion_Async() + public async Task Example_ProjectMetadata_GetProjectDetails_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = await client.GetProjectDetailsAsync(""); + Response response = await client.GetProjectDetailsAsync("", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("projectName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ProjectMetadata_GetProjectDetails_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = client.GetProjectDetails(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ProjectMetadata_GetProjectDetails_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = await client.GetProjectDetailsAsync(""); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetProjectDetails_AllParameters() + public void Example_ProjectMetadata_GetProjectDetails_AllParameters() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = client.GetProjectDetails(""); + Response response = client.GetProjectDetails("", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("projectName").ToString()); @@ -68,13 +89,13 @@ public void Example_GetProjectDetails_AllParameters() [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetProjectDetails_AllParameters_Async() + public async Task Example_ProjectMetadata_GetProjectDetails_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = await client.GetProjectDetailsAsync(""); + Response response = await client.GetProjectDetailsAsync("", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("projectName").ToString()); @@ -89,11 +110,33 @@ public async Task Example_GetProjectDetails_AllParameters_Async() [Test] [Ignore("Only validating compilation of examples")] - public void Example_CreateProject_ShortVersion() + public void Example_ProjectMetadata_GetProjectDetails_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = client.GetProjectDetails(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ProjectMetadata_GetProjectDetails_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = await client.GetProjectDetailsAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ProjectMetadata_CreateProject_ShortVersion() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new { @@ -102,16 +145,16 @@ public void Example_CreateProject_ShortVersion() Response response = client.CreateProject("", content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("projectName").ToString()); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_CreateProject_ShortVersion_Async() + public async Task Example_ProjectMetadata_CreateProject_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new { @@ -120,16 +163,16 @@ public async Task Example_CreateProject_ShortVersion_Async() Response response = await client.CreateProjectAsync("", content); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("projectName").ToString()); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_CreateProject_AllParameters() + public void Example_ProjectMetadata_CreateProject_AllParameters() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new { @@ -156,11 +199,11 @@ public void Example_CreateProject_AllParameters() [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_CreateProject_AllParameters_Async() + public async Task Example_ProjectMetadata_CreateProject_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new { @@ -187,13 +230,13 @@ public async Task Example_CreateProject_AllParameters_Async() [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetDeleteStatus_ShortVersion() + public void Example_QuestionAnsweringAuthoringProjectDeletionJobState_GetDeleteStatus_ShortVersion() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = client.GetDeleteStatus(""); + Response response = client.GetDeleteStatus("", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("createdDateTime").ToString()); @@ -204,13 +247,13 @@ public void Example_GetDeleteStatus_ShortVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetDeleteStatus_ShortVersion_Async() + public async Task Example_QuestionAnsweringAuthoringProjectDeletionJobState_GetDeleteStatus_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = await client.GetDeleteStatusAsync(""); + Response response = await client.GetDeleteStatusAsync("", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("createdDateTime").ToString()); @@ -221,15 +264,42 @@ public async Task Example_GetDeleteStatus_ShortVersion_Async() [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetDeleteStatus_AllParameters() + public void Example_QuestionAnsweringAuthoringProjectDeletionJobState_GetDeleteStatus_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = client.GetDeleteStatus(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringAuthoringProjectDeletionJobState_GetDeleteStatus_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = await client.GetDeleteStatusAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnsweringAuthoringProjectDeletionJobState_GetDeleteStatus_AllParameters() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = client.GetDeleteStatus(""); + Response response = client.GetDeleteStatus("", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); + Console.WriteLine(result.GetProperty("jobId").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -244,24 +314,24 @@ public void Example_GetDeleteStatus_AllParameters() Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetDeleteStatus_AllParameters_Async() + public async Task Example_QuestionAnsweringAuthoringProjectDeletionJobState_GetDeleteStatus_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = await client.GetDeleteStatusAsync(""); + Response response = await client.GetDeleteStatusAsync("", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); + Console.WriteLine(result.GetProperty("jobId").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -276,61 +346,104 @@ public async Task Example_GetDeleteStatus_AllParameters_Async() Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetExportStatus_ShortVersion() + public void Example_QuestionAnsweringAuthoringProjectDeletionJobState_GetDeleteStatus_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = client.GetDeleteStatus(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringAuthoringProjectDeletionJobState_GetDeleteStatus_AllParameters_Convenience_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = client.GetExportStatus("", ""); + Response response = await client.GetDeleteStatusAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnsweringAuthoringExportJobState_GetExportStatus_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = client.GetExportStatus("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("resultUrl").ToString()); Console.WriteLine(result.GetProperty("createdDateTime").ToString()); Console.WriteLine(result.GetProperty("jobId").ToString()); Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("resultUrl").ToString()); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetExportStatus_ShortVersion_Async() + public async Task Example_QuestionAnsweringAuthoringExportJobState_GetExportStatus_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = await client.GetExportStatusAsync("", ""); + Response response = await client.GetExportStatusAsync("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("resultUrl").ToString()); Console.WriteLine(result.GetProperty("createdDateTime").ToString()); Console.WriteLine(result.GetProperty("jobId").ToString()); Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("resultUrl").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnsweringAuthoringExportJobState_GetExportStatus_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = client.GetExportStatus("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringAuthoringExportJobState_GetExportStatus_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = await client.GetExportStatusAsync("", ""); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetExportStatus_AllParameters() + public void Example_QuestionAnsweringAuthoringExportJobState_GetExportStatus_AllParameters() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = client.GetExportStatus("", ""); + Response response = client.GetExportStatus("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("resultUrl").ToString()); + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); + Console.WriteLine(result.GetProperty("jobId").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -345,25 +458,25 @@ public void Example_GetExportStatus_AllParameters() Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("resultUrl").ToString()); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetExportStatus_AllParameters_Async() + public async Task Example_QuestionAnsweringAuthoringExportJobState_GetExportStatus_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = await client.GetExportStatusAsync("", ""); + Response response = await client.GetExportStatusAsync("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("resultUrl").ToString()); + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); + Console.WriteLine(result.GetProperty("jobId").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -378,22 +491,40 @@ public async Task Example_GetExportStatus_AllParameters_Async() Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("resultUrl").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnsweringAuthoringExportJobState_GetExportStatus_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = client.GetExportStatus("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringAuthoringExportJobState_GetExportStatus_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = await client.GetExportStatusAsync("", ""); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetImportStatus_ShortVersion() + public void Example_QuestionAnsweringAuthoringImportJobState_GetImportStatus_ShortVersion() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = client.GetImportStatus("", ""); + Response response = client.GetImportStatus("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("createdDateTime").ToString()); @@ -404,13 +535,13 @@ public void Example_GetImportStatus_ShortVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetImportStatus_ShortVersion_Async() + public async Task Example_QuestionAnsweringAuthoringImportJobState_GetImportStatus_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = await client.GetImportStatusAsync("", ""); + Response response = await client.GetImportStatusAsync("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("createdDateTime").ToString()); @@ -421,15 +552,42 @@ public async Task Example_GetImportStatus_ShortVersion_Async() [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetImportStatus_AllParameters() + public void Example_QuestionAnsweringAuthoringImportJobState_GetImportStatus_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = client.GetImportStatus("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringAuthoringImportJobState_GetImportStatus_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = await client.GetImportStatusAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnsweringAuthoringImportJobState_GetImportStatus_AllParameters() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = client.GetImportStatus("", ""); + Response response = client.GetImportStatus("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); + Console.WriteLine(result.GetProperty("jobId").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -444,24 +602,24 @@ public void Example_GetImportStatus_AllParameters() Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetImportStatus_AllParameters_Async() + public async Task Example_QuestionAnsweringAuthoringImportJobState_GetImportStatus_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = await client.GetImportStatusAsync("", ""); + Response response = await client.GetImportStatusAsync("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); + Console.WriteLine(result.GetProperty("jobId").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -476,22 +634,39 @@ public async Task Example_GetImportStatus_AllParameters_Async() Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetDeployStatus_ShortVersion() + public void Example_QuestionAnsweringAuthoringImportJobState_GetImportStatus_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = client.GetImportStatus("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringAuthoringImportJobState_GetImportStatus_AllParameters_Convenience_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = client.GetDeployStatus("", "", ""); + Response response = await client.GetImportStatusAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnsweringAuthoringProjectDeploymentJobState_GetDeployStatus_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = client.GetDeployStatus("", "", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("createdDateTime").ToString()); @@ -502,13 +677,13 @@ public void Example_GetDeployStatus_ShortVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetDeployStatus_ShortVersion_Async() + public async Task Example_QuestionAnsweringAuthoringProjectDeploymentJobState_GetDeployStatus_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = await client.GetDeployStatusAsync("", "", ""); + Response response = await client.GetDeployStatusAsync("", "", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("createdDateTime").ToString()); @@ -519,15 +694,42 @@ public async Task Example_GetDeployStatus_ShortVersion_Async() [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetDeployStatus_AllParameters() + public void Example_QuestionAnsweringAuthoringProjectDeploymentJobState_GetDeployStatus_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = client.GetDeployStatus("", "", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringAuthoringProjectDeploymentJobState_GetDeployStatus_ShortVersion_Convenience_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = client.GetDeployStatus("", "", ""); + Response response = await client.GetDeployStatusAsync("", "", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnsweringAuthoringProjectDeploymentJobState_GetDeployStatus_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = client.GetDeployStatus("", "", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); + Console.WriteLine(result.GetProperty("jobId").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -542,24 +744,24 @@ public void Example_GetDeployStatus_AllParameters() Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetDeployStatus_AllParameters_Async() + public async Task Example_QuestionAnsweringAuthoringProjectDeploymentJobState_GetDeployStatus_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = await client.GetDeployStatusAsync("", "", ""); + Response response = await client.GetDeployStatusAsync("", "", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); + Console.WriteLine(result.GetProperty("jobId").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -574,48 +776,37 @@ public async Task Example_GetDeployStatus_AllParameters_Async() Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_UpdateSynonyms_ShortVersion() + public void Example_QuestionAnsweringAuthoringProjectDeploymentJobState_GetDeployStatus_AllParameters_Convenience() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - using RequestContent content = RequestContent.Create(new object()); - Response response = client.UpdateSynonyms("", content); - - Console.WriteLine(response.Status); + Response response = client.GetDeployStatus("", "", ""); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_UpdateSynonyms_ShortVersion_Async() + public async Task Example_QuestionAnsweringAuthoringProjectDeploymentJobState_GetDeployStatus_AllParameters_Convenience_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - using RequestContent content = RequestContent.Create(new object()); - Response response = await client.UpdateSynonymsAsync("", content); - - Console.WriteLine(response.Status); + Response response = await client.GetDeployStatusAsync("", "", ""); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_UpdateSynonyms_AllParameters() + public void Example_QuestionAnsweringProjects_UpdateSynonyms_ShortVersion() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new { @@ -629,7 +820,6 @@ public void Example_UpdateSynonyms_AllParameters() }, } }, - nextLink = "", }); Response response = client.UpdateSynonyms("", content); @@ -638,11 +828,11 @@ public void Example_UpdateSynonyms_AllParameters() [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_UpdateSynonyms_AllParameters_Async() + public async Task Example_QuestionAnsweringProjects_UpdateSynonyms_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new { @@ -656,7 +846,6 @@ public async Task Example_UpdateSynonyms_AllParameters_Async() }, } }, - nextLink = "", }); Response response = await client.UpdateSynonymsAsync("", content); @@ -665,32 +854,135 @@ public async Task Example_UpdateSynonyms_AllParameters_Async() [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetUpdateSourcesStatus_ShortVersion() + public void Example_QuestionAnsweringProjects_UpdateSynonyms_ShortVersion_Convenience() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = client.GetUpdateSourcesStatus("", ""); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); + SynonymAssets body = new SynonymAssets(new WordAlterations[] + { +new WordAlterations(new string[]{""}) + }); + Response response = client.UpdateSynonyms("", body); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetUpdateSourcesStatus_ShortVersion_Async() + public async Task Example_QuestionAnsweringProjects_UpdateSynonyms_ShortVersion_Convenience_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = await client.GetUpdateSourcesStatusAsync("", ""); + SynonymAssets body = new SynonymAssets(new WordAlterations[] + { +new WordAlterations(new string[]{""}) + }); + Response response = await client.UpdateSynonymsAsync("", body); + } - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnsweringProjects_UpdateSynonyms_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + using RequestContent content = RequestContent.Create(new + { + value = new object[] + { +new +{ +alterations = new object[] +{ +"" +}, +} + }, + nextLink = "http://localhost:3000", + }); + Response response = client.UpdateSynonyms("", content); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringProjects_UpdateSynonyms_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + using RequestContent content = RequestContent.Create(new + { + value = new object[] + { +new +{ +alterations = new object[] +{ +"" +}, +} + }, + nextLink = "http://localhost:3000", + }); + Response response = await client.UpdateSynonymsAsync("", content); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnsweringProjects_UpdateSynonyms_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + SynonymAssets body = new SynonymAssets(new WordAlterations[] + { +new WordAlterations(new string[]{""}) + }) + { + NextLink = new Uri("http://localhost:3000"), + }; + Response response = client.UpdateSynonyms("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringProjects_UpdateSynonyms_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + SynonymAssets body = new SynonymAssets(new WordAlterations[] + { +new WordAlterations(new string[]{""}) + }) + { + NextLink = new Uri("http://localhost:3000"), + }; + Response response = await client.UpdateSynonymsAsync("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnsweringAuthoringUpdateSourcesJobState_GetUpdateSourcesStatus_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = client.GetUpdateSourcesStatus("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("createdDateTime").ToString()); Console.WriteLine(result.GetProperty("jobId").ToString()); Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); @@ -699,15 +991,59 @@ public async Task Example_GetUpdateSourcesStatus_ShortVersion_Async() [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetUpdateSourcesStatus_AllParameters() + public async Task Example_QuestionAnsweringAuthoringUpdateSourcesJobState_GetUpdateSourcesStatus_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = await client.GetUpdateSourcesStatusAsync("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("jobId").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnsweringAuthoringUpdateSourcesJobState_GetUpdateSourcesStatus_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = client.GetUpdateSourcesStatus("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringAuthoringUpdateSourcesJobState_GetUpdateSourcesStatus_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = await client.GetUpdateSourcesStatusAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnsweringAuthoringUpdateSourcesJobState_GetUpdateSourcesStatus_AllParameters() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = client.GetUpdateSourcesStatus("", ""); + Response response = client.GetUpdateSourcesStatus("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); + Console.WriteLine(result.GetProperty("jobId").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -722,24 +1058,24 @@ public void Example_GetUpdateSourcesStatus_AllParameters() Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetUpdateSourcesStatus_AllParameters_Async() + public async Task Example_QuestionAnsweringAuthoringUpdateSourcesJobState_GetUpdateSourcesStatus_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = await client.GetUpdateSourcesStatusAsync("", ""); + Response response = await client.GetUpdateSourcesStatusAsync("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); + Console.WriteLine(result.GetProperty("jobId").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -754,22 +1090,39 @@ public async Task Example_GetUpdateSourcesStatus_AllParameters_Async() Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetUpdateQnasStatus_ShortVersion() + public void Example_QuestionAnsweringAuthoringUpdateSourcesJobState_GetUpdateSourcesStatus_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = client.GetUpdateSourcesStatus("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringAuthoringUpdateSourcesJobState_GetUpdateSourcesStatus_AllParameters_Convenience_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = client.GetUpdateQnasStatus("", ""); + Response response = await client.GetUpdateSourcesStatusAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnsweringAuthoringUpdateQnasJobState_GetUpdateQnasStatus_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = client.GetUpdateQnasStatus("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("createdDateTime").ToString()); @@ -780,13 +1133,13 @@ public void Example_GetUpdateQnasStatus_ShortVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetUpdateQnasStatus_ShortVersion_Async() + public async Task Example_QuestionAnsweringAuthoringUpdateQnasJobState_GetUpdateQnasStatus_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = await client.GetUpdateQnasStatusAsync("", ""); + Response response = await client.GetUpdateQnasStatusAsync("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("createdDateTime").ToString()); @@ -797,15 +1150,42 @@ public async Task Example_GetUpdateQnasStatus_ShortVersion_Async() [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetUpdateQnasStatus_AllParameters() + public void Example_QuestionAnsweringAuthoringUpdateQnasJobState_GetUpdateQnasStatus_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = client.GetUpdateQnasStatus("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringAuthoringUpdateQnasJobState_GetUpdateQnasStatus_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = await client.GetUpdateQnasStatusAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnsweringAuthoringUpdateQnasJobState_GetUpdateQnasStatus_AllParameters() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = client.GetUpdateQnasStatus("", ""); + Response response = client.GetUpdateQnasStatus("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); + Console.WriteLine(result.GetProperty("jobId").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -820,24 +1200,24 @@ public void Example_GetUpdateQnasStatus_AllParameters() Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetUpdateQnasStatus_AllParameters_Async() + public async Task Example_QuestionAnsweringAuthoringUpdateQnasJobState_GetUpdateQnasStatus_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Response response = await client.GetUpdateQnasStatusAsync("", ""); + Response response = await client.GetUpdateQnasStatusAsync("", "", null); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("createdDateTime").ToString()); + Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); + Console.WriteLine(result.GetProperty("jobId").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); @@ -852,20 +1232,37 @@ public async Task Example_GetUpdateQnasStatus_AllParameters_Async() Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_AddFeedback_ShortVersion() + public void Example_QuestionAnsweringAuthoringUpdateQnasJobState_GetUpdateQnasStatus_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = client.GetUpdateQnasStatus("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringAuthoringUpdateQnasJobState_GetUpdateQnasStatus_AllParameters_Convenience_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Response response = await client.GetUpdateQnasStatusAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnsweringProjects_AddFeedback_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object()); Response response = client.AddFeedback("", content); @@ -875,11 +1272,11 @@ public void Example_AddFeedback_ShortVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_AddFeedback_ShortVersion_Async() + public async Task Example_QuestionAnsweringProjects_AddFeedback_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object()); Response response = await client.AddFeedbackAsync("", content); @@ -889,11 +1286,35 @@ public async Task Example_AddFeedback_ShortVersion_Async() [Test] [Ignore("Only validating compilation of examples")] - public void Example_AddFeedback_AllParameters() + public void Example_QuestionAnsweringProjects_AddFeedback_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + ActiveLearningFeedback body = new ActiveLearningFeedback(); + Response response = client.AddFeedback("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringProjects_AddFeedback_ShortVersion_Convenience_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + ActiveLearningFeedback body = new ActiveLearningFeedback(); + Response response = await client.AddFeedbackAsync("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnsweringProjects_AddFeedback_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new { @@ -914,11 +1335,11 @@ public void Example_AddFeedback_AllParameters() [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_AddFeedback_AllParameters_Async() + public async Task Example_QuestionAnsweringProjects_AddFeedback_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new { @@ -939,43 +1360,109 @@ public async Task Example_AddFeedback_AllParameters_Async() [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetProjects_ShortVersion() + public void Example_QuestionAnsweringProjects_AddFeedback_AllParameters_Convenience() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - foreach (BinaryData item in client.GetProjects()) + ActiveLearningFeedback body = new ActiveLearningFeedback + { + Records = {new FeedbackRecord +{ +UserId = "", +UserQuestion = "", +QnaId = 1234, +}}, + }; + Response response = client.AddFeedback("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringProjects_AddFeedback_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + ActiveLearningFeedback body = new ActiveLearningFeedback + { + Records = {new FeedbackRecord +{ +UserId = "", +UserQuestion = "", +QnaId = 1234, +}}, + }; + Response response = await client.AddFeedbackAsync("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ProjectMetadata_GetProjects_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + foreach (BinaryData item in client.GetProjects(null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("projectName").ToString()); } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetProjects_ShortVersion_Async() + public async Task Example_ProjectMetadata_GetProjects_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - await foreach (BinaryData item in client.GetProjectsAsync()) + await foreach (BinaryData item in client.GetProjectsAsync(null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("projectName").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ProjectMetadata_GetProjects_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + foreach (ProjectMetadata item in client.GetProjects()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ProjectMetadata_GetProjects_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + await foreach (ProjectMetadata item in client.GetProjectsAsync()) + { } } [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetProjects_AllParameters() + public void Example_ProjectMetadata_GetProjects_AllParameters() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - foreach (BinaryData item in client.GetProjects()) + foreach (BinaryData item in client.GetProjects(1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; Console.WriteLine(result.GetProperty("projectName").ToString()); @@ -991,13 +1478,13 @@ public void Example_GetProjects_AllParameters() [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetProjects_AllParameters_Async() + public async Task Example_ProjectMetadata_GetProjects_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - await foreach (BinaryData item in client.GetProjectsAsync()) + await foreach (BinaryData item in client.GetProjectsAsync(1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; Console.WriteLine(result.GetProperty("projectName").ToString()); @@ -1013,43 +1500,95 @@ public async Task Example_GetProjects_AllParameters_Async() [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetDeployments_ShortVersion() + public void Example_ProjectMetadata_GetProjects_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + foreach (ProjectMetadata item in client.GetProjects(maxCount: 1234, skip: 1234, maxpagesize: 1234)) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ProjectMetadata_GetProjects_AllParameters_Convenience_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - foreach (BinaryData item in client.GetDeployments("")) + await foreach (ProjectMetadata item in client.GetProjectsAsync(maxCount: 1234, skip: 1234, maxpagesize: 1234)) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ProjectDeployment_GetDeployments_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + foreach (BinaryData item in client.GetDeployments("", null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("deploymentName").ToString()); } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetDeployments_ShortVersion_Async() + public async Task Example_ProjectDeployment_GetDeployments_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - await foreach (BinaryData item in client.GetDeploymentsAsync("")) + await foreach (BinaryData item in client.GetDeploymentsAsync("", null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("deploymentName").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ProjectDeployment_GetDeployments_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + foreach (ProjectDeployment item in client.GetDeployments("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ProjectDeployment_GetDeployments_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + await foreach (ProjectDeployment item in client.GetDeploymentsAsync("")) + { } } [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetDeployments_AllParameters() + public void Example_ProjectDeployment_GetDeployments_AllParameters() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - foreach (BinaryData item in client.GetDeployments("")) + foreach (BinaryData item in client.GetDeployments("", 1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; Console.WriteLine(result.GetProperty("deploymentName").ToString()); @@ -1059,13 +1598,13 @@ public void Example_GetDeployments_AllParameters() [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetDeployments_AllParameters_Async() + public async Task Example_ProjectDeployment_GetDeployments_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - await foreach (BinaryData item in client.GetDeploymentsAsync("")) + await foreach (BinaryData item in client.GetDeploymentsAsync("", 1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; Console.WriteLine(result.GetProperty("deploymentName").ToString()); @@ -1075,13 +1614,39 @@ public async Task Example_GetDeployments_AllParameters_Async() [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetSynonyms_ShortVersion() + public void Example_ProjectDeployment_GetDeployments_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + foreach (ProjectDeployment item in client.GetDeployments("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ProjectDeployment_GetDeployments_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + await foreach (ProjectDeployment item in client.GetDeploymentsAsync("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_WordAlterations_GetSynonyms_ShortVersion() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - foreach (BinaryData item in client.GetSynonyms("")) + foreach (BinaryData item in client.GetSynonyms("", null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; Console.WriteLine(result.GetProperty("alterations")[0].ToString()); @@ -1090,13 +1655,13 @@ public void Example_GetSynonyms_ShortVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetSynonyms_ShortVersion_Async() + public async Task Example_WordAlterations_GetSynonyms_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - await foreach (BinaryData item in client.GetSynonymsAsync("")) + await foreach (BinaryData item in client.GetSynonymsAsync("", null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; Console.WriteLine(result.GetProperty("alterations")[0].ToString()); @@ -1105,13 +1670,39 @@ public async Task Example_GetSynonyms_ShortVersion_Async() [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetSynonyms_AllParameters() + public void Example_WordAlterations_GetSynonyms_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + foreach (WordAlterations item in client.GetSynonyms("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_WordAlterations_GetSynonyms_ShortVersion_Convenience_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - foreach (BinaryData item in client.GetSynonyms("")) + await foreach (WordAlterations item in client.GetSynonymsAsync("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_WordAlterations_GetSynonyms_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + foreach (BinaryData item in client.GetSynonyms("", 1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; Console.WriteLine(result.GetProperty("alterations")[0].ToString()); @@ -1120,13 +1711,13 @@ public void Example_GetSynonyms_AllParameters() [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetSynonyms_AllParameters_Async() + public async Task Example_WordAlterations_GetSynonyms_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - await foreach (BinaryData item in client.GetSynonymsAsync("")) + await foreach (BinaryData item in client.GetSynonymsAsync("", 1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; Console.WriteLine(result.GetProperty("alterations")[0].ToString()); @@ -1135,15 +1726,42 @@ public async Task Example_GetSynonyms_AllParameters_Async() [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetSources_ShortVersion() + public void Example_WordAlterations_GetSynonyms_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + foreach (WordAlterations item in client.GetSynonyms("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_WordAlterations_GetSynonyms_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + await foreach (WordAlterations item in client.GetSynonymsAsync("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QnaSourceRecord_GetSources_ShortVersion() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - foreach (BinaryData item in client.GetSources("")) + foreach (BinaryData item in client.GetSources("", null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("source").ToString()); Console.WriteLine(result.GetProperty("sourceUri").ToString()); Console.WriteLine(result.GetProperty("sourceKind").ToString()); } @@ -1151,15 +1769,16 @@ public void Example_GetSources_ShortVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetSources_ShortVersion_Async() + public async Task Example_QnaSourceRecord_GetSources_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - await foreach (BinaryData item in client.GetSourcesAsync("")) + await foreach (BinaryData item in client.GetSourcesAsync("", null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("source").ToString()); Console.WriteLine(result.GetProperty("sourceUri").ToString()); Console.WriteLine(result.GetProperty("sourceKind").ToString()); } @@ -1167,86 +1786,163 @@ public async Task Example_GetSources_ShortVersion_Async() [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetSources_AllParameters() + public void Example_QnaSourceRecord_GetSources_ShortVersion_Convenience() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - foreach (BinaryData item in client.GetSources("")) + foreach (QnaSourceRecord item in client.GetSources("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QnaSourceRecord_GetSources_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + await foreach (QnaSourceRecord item in client.GetSourcesAsync("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QnaSourceRecord_GetSources_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + foreach (BinaryData item in client.GetSources("", 1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); Console.WriteLine(result.GetProperty("displayName").ToString()); Console.WriteLine(result.GetProperty("source").ToString()); Console.WriteLine(result.GetProperty("sourceUri").ToString()); Console.WriteLine(result.GetProperty("sourceKind").ToString()); Console.WriteLine(result.GetProperty("contentStructureKind").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetSources_AllParameters_Async() + public async Task Example_QnaSourceRecord_GetSources_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - await foreach (BinaryData item in client.GetSourcesAsync("")) + await foreach (BinaryData item in client.GetSourcesAsync("", 1234, 1234, 1234, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); Console.WriteLine(result.GetProperty("displayName").ToString()); Console.WriteLine(result.GetProperty("source").ToString()); Console.WriteLine(result.GetProperty("sourceUri").ToString()); Console.WriteLine(result.GetProperty("sourceKind").ToString()); Console.WriteLine(result.GetProperty("contentStructureKind").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); } } [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetQnas_ShortVersion() + public void Example_QnaSourceRecord_GetSources_AllParameters_Convenience() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - foreach (BinaryData item in client.GetQnas("")) + foreach (QnaSourceRecord item in client.GetSources("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QnaSourceRecord_GetSources_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + await foreach (QnaSourceRecord item in client.GetSourcesAsync("", maxCount: 1234, skip: 1234, maxpagesize: 1234)) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RetrieveQnaRecord_GetQnas_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + foreach (BinaryData item in client.GetQnas("", null, null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetQnas_ShortVersion_Async() + public async Task Example_RetrieveQnaRecord_GetQnas_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - await foreach (BinaryData item in client.GetQnasAsync("")) + await foreach (BinaryData item in client.GetQnasAsync("", null, null, null, null, null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); } } [Test] [Ignore("Only validating compilation of examples")] - public void Example_GetQnas_AllParameters() + public void Example_RetrieveQnaRecord_GetQnas_ShortVersion_Convenience() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - foreach (BinaryData item in client.GetQnas("", source: "")) + foreach (RetrieveQnaRecord item in client.GetQnas("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RetrieveQnaRecord_GetQnas_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + await foreach (RetrieveQnaRecord item in client.GetQnasAsync("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RetrieveQnaRecord_GetQnas_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + foreach (BinaryData item in client.GetQnas("", 1234, 1234, 1234, "", null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); Console.WriteLine(result.GetProperty("id").ToString()); Console.WriteLine(result.GetProperty("answer").ToString()); Console.WriteLine(result.GetProperty("source").ToString()); @@ -1269,21 +1965,21 @@ public void Example_GetQnas_AllParameters() Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("question").ToString()); Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("userSuggestedCount").ToString()); Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("autoSuggestedCount").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_GetQnas_AllParameters_Async() + public async Task Example_RetrieveQnaRecord_GetQnas_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - await foreach (BinaryData item in client.GetQnasAsync("", source: "")) + await foreach (BinaryData item in client.GetQnasAsync("", 1234, 1234, 1234, "", null)) { JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); Console.WriteLine(result.GetProperty("id").ToString()); Console.WriteLine(result.GetProperty("answer").ToString()); Console.WriteLine(result.GetProperty("source").ToString()); @@ -1306,204 +2002,221 @@ public async Task Example_GetQnas_AllParameters_Async() Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("question").ToString()); Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("userSuggestedCount").ToString()); Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("autoSuggestedCount").ToString()); + Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); } } [Test] [Ignore("Only validating compilation of examples")] - public void Example_DeleteProject_ShortVersion() + public void Example_RetrieveQnaRecord_GetQnas_AllParameters_Convenience() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + foreach (RetrieveQnaRecord item in client.GetQnas("", maxCount: 1234, skip: 1234, maxpagesize: 1234, source: "")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RetrieveQnaRecord_GetQnas_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + await foreach (RetrieveQnaRecord item in client.GetQnasAsync("", maxCount: 1234, skip: 1234, maxpagesize: 1234, source: "")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnsweringProjects_DeleteProject_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); Operation operation = client.DeleteProject(WaitUntil.Completed, ""); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_DeleteProject_ShortVersion_Async() + public async Task Example_QuestionAnsweringProjects_DeleteProject_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); Operation operation = await client.DeleteProjectAsync(WaitUntil.Completed, ""); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_DeleteProject_AllParameters() + public void Example_QuestionAnsweringProjects_DeleteProject_AllParameters() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); Operation operation = client.DeleteProject(WaitUntil.Completed, ""); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_DeleteProject_AllParameters_Async() + public async Task Example_QuestionAnsweringProjects_DeleteProject_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); Operation operation = await client.DeleteProjectAsync(WaitUntil.Completed, ""); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_Export_ShortVersion() + public void Example_QuestionAnsweringProjects_Export_ShortVersion() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Operation operation = client.Export(WaitUntil.Completed, ""); - BinaryData responseData = operation.Value; + Operation operation = client.Export(WaitUntil.Completed, "", null, null, null); + } - JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("resultUrl").ToString()); - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringProjects_Export_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Operation operation = await client.ExportAsync(WaitUntil.Completed, "", null, null, null); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_Export_ShortVersion_Async() + public void Example_QuestionAnsweringProjects_Export_ShortVersion_Convenience() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Operation operation = await client.ExportAsync(WaitUntil.Completed, ""); - BinaryData responseData = operation.Value; + Operation operation = client.Export(WaitUntil.Completed, ""); + } - JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("resultUrl").ToString()); - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringProjects_Export_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Operation operation = await client.ExportAsync(WaitUntil.Completed, ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnsweringProjects_Export_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Operation operation = client.Export(WaitUntil.Completed, "", "json", "qnas", null); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringProjects_Export_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Operation operation = await client.ExportAsync(WaitUntil.Completed, "", "json", "qnas", null); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnsweringProjects_Export_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Operation operation = client.Export(WaitUntil.Completed, "", format: ImportExportFormat.Json, assetKind: AssestKind.Qnas); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_Export_AllParameters() + public async Task Example_QuestionAnsweringProjects_Export_AllParameters_Convenience_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Operation operation = client.Export(WaitUntil.Completed, "", format: "json", assetKind: "qnas"); - BinaryData responseData = operation.Value; - - JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("resultUrl").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("code").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("message").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("code").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("message").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("code").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); + Operation operation = await client.ExportAsync(WaitUntil.Completed, "", format: ImportExportFormat.Json, assetKind: AssestKind.Qnas); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_Export_AllParameters_Async() + public void Example_QuestionAnsweringProjects_Import_ShortVersion() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); - - Operation operation = await client.ExportAsync(WaitUntil.Completed, "", format: "json", assetKind: "qnas"); - BinaryData responseData = operation.Value; + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("resultUrl").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("code").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("message").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("code").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("message").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("code").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); + using RequestContent content = null; + Operation operation = client.Import(WaitUntil.Completed, "", content); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_Import_ShortVersion() + public async Task Example_QuestionAnsweringProjects_Import_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = null; - Operation operation = client.Import(WaitUntil.Completed, "", content); - BinaryData responseData = operation.Value; - - JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); + Operation operation = await client.ImportAsync(WaitUntil.Completed, "", content); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_Import_ShortVersion_Async() + public void Example_QuestionAnsweringProjects_Import_ShortVersion_Convenience() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - using RequestContent content = null; - Operation operation = await client.ImportAsync(WaitUntil.Completed, "", content); - BinaryData responseData = operation.Value; + Operation operation = client.Import(WaitUntil.Completed, ""); + } - JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringProjects_Import_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Operation operation = await client.ImportAsync(WaitUntil.Completed, ""); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_Import_AllParameters() + public void Example_QuestionAnsweringProjects_Import_AllParameters() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new { @@ -1533,9 +2246,6 @@ public void Example_Import_AllParameters() { new { -sourceDisplayName = "", -lastUpdatedDateTime = "2022-05-10T18:57:31.2311892Z", -id = 1234, answer = "", source = "", questions = new object[] @@ -1557,7 +2267,6 @@ public void Example_Import_AllParameters() qnaId = 1234, qna = new { -id = 1234, answer = "", source = "", questions = new object[] @@ -1593,43 +2302,23 @@ public void Example_Import_AllParameters() { null }, +lastUpdatedDateTime = "2022-05-10T18:57:31.2311892Z", +sourceDisplayName = "", } }, }, fileUri = "", }); - Operation operation = client.Import(WaitUntil.Completed, "", content, format: "json", assetKind: "qnas"); - BinaryData responseData = operation.Value; - - JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("code").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("message").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("code").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("message").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("code").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); + Operation operation = client.Import(WaitUntil.Completed, "", content, format: "json", assetKind: "qnas"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_Import_AllParameters_Async() + public async Task Example_QuestionAnsweringProjects_Import_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new { @@ -1659,9 +2348,6 @@ public async Task Example_Import_AllParameters_Async() { new { -sourceDisplayName = "", -lastUpdatedDateTime = "2022-05-10T18:57:31.2311892Z", -id = 1234, answer = "", source = "", questions = new object[] @@ -1683,7 +2369,6 @@ public async Task Example_Import_AllParameters_Async() qnaId = 1234, qna = new { -id = 1234, answer = "", source = "", questions = new object[] @@ -1719,105 +2404,211 @@ public async Task Example_Import_AllParameters_Async() { null }, +lastUpdatedDateTime = "2022-05-10T18:57:31.2311892Z", +sourceDisplayName = "", } }, }, fileUri = "", }); - Operation operation = await client.ImportAsync(WaitUntil.Completed, "", content, format: "json", assetKind: "qnas"); - BinaryData responseData = operation.Value; - - JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("code").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("message").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("code").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("message").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("code").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("message").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("details")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("code").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("message").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("details").GetProperty("").ToString()); - Console.WriteLine(result.GetProperty("errors")[0].GetProperty("innererror").GetProperty("target").ToString()); - Console.WriteLine(result.GetProperty("createdDateTime").ToString()); - Console.WriteLine(result.GetProperty("expirationDateTime").ToString()); - Console.WriteLine(result.GetProperty("jobId").ToString()); - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("status").ToString()); + Operation operation = await client.ImportAsync(WaitUntil.Completed, "", content, format: "json", assetKind: "qnas"); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_DeployProject_ShortVersion() + public void Example_QuestionAnsweringProjects_Import_AllParameters_Convenience() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Operation operation = client.DeployProject(WaitUntil.Completed, "", ""); - BinaryData responseData = operation.Value; - - JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; - Console.WriteLine(result.ToString()); + ImportJobOptions body = new ImportJobOptions + { + Metadata = new CreateProjectOptions("") + { + Description = "", + MultilingualResource = true, + Settings = new ProjectSettings + { + DefaultAnswer = "", + }, + }, + Assets = new Assets + { + Synonyms = { new WordAlterations(new string[] { "" }) }, + Qnas = {new ImportQnaRecord +{ +Answer = "", +Source = "", +Questions = {""}, +Metadata = +{ +["key"] = "" +}, +Dialog = new QnaDialog +{ +IsContextOnly = true, +Prompts = {new QnaPrompt +{ +DisplayOrder = 1234, +QnaId = 1234, +Qna = new QnaRecord +{ +Answer = "", +Source = "", +Questions = {""}, +Metadata = +{ +["key"] = "" +}, +Dialog = default, +ActiveLearningSuggestions = {new SuggestedQuestionsCluster +{ +ClusterHead = "", +SuggestedQuestions = {new SuggestedQuestion +{ +Question = "", +UserSuggestedCount = 1234, +AutoSuggestedCount = 1234, +}}, +}}, +}, +DisplayText = "", +}}, +}, +ActiveLearningSuggestions = {default}, +LastUpdatedDateTime = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), +SourceDisplayName = "", +}}, + }, + FileUri = "", + }; + Operation operation = client.Import(WaitUntil.Completed, "", body: body, format: ImportExportFormat.Json, assetKind: AssestKind.Qnas); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_DeployProject_ShortVersion_Async() + public async Task Example_QuestionAnsweringProjects_Import_AllParameters_Convenience_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Operation operation = await client.DeployProjectAsync(WaitUntil.Completed, "", ""); - BinaryData responseData = operation.Value; - - JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; - Console.WriteLine(result.ToString()); + ImportJobOptions body = new ImportJobOptions + { + Metadata = new CreateProjectOptions("") + { + Description = "", + MultilingualResource = true, + Settings = new ProjectSettings + { + DefaultAnswer = "", + }, + }, + Assets = new Assets + { + Synonyms = { new WordAlterations(new string[] { "" }) }, + Qnas = {new ImportQnaRecord +{ +Answer = "", +Source = "", +Questions = {""}, +Metadata = +{ +["key"] = "" +}, +Dialog = new QnaDialog +{ +IsContextOnly = true, +Prompts = {new QnaPrompt +{ +DisplayOrder = 1234, +QnaId = 1234, +Qna = new QnaRecord +{ +Answer = "", +Source = "", +Questions = {""}, +Metadata = +{ +["key"] = "" +}, +Dialog = default, +ActiveLearningSuggestions = {new SuggestedQuestionsCluster +{ +ClusterHead = "", +SuggestedQuestions = {new SuggestedQuestion +{ +Question = "", +UserSuggestedCount = 1234, +AutoSuggestedCount = 1234, +}}, +}}, +}, +DisplayText = "", +}}, +}, +ActiveLearningSuggestions = {default}, +LastUpdatedDateTime = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), +SourceDisplayName = "", +}}, + }, + FileUri = "", + }; + Operation operation = await client.ImportAsync(WaitUntil.Completed, "", body: body, format: ImportExportFormat.Json, assetKind: AssestKind.Qnas); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_DeployProject_AllParameters() + public void Example_QuestionAnsweringProjects_DeployProject_ShortVersion() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Operation operation = client.DeployProject(WaitUntil.Completed, "", ""); - BinaryData responseData = operation.Value; + Operation operation = client.DeployProject(WaitUntil.Completed, "", ""); + } - JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("deploymentName").ToString()); - Console.WriteLine(result.GetProperty("lastDeployedDateTime").ToString()); + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringProjects_DeployProject_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Operation operation = await client.DeployProjectAsync(WaitUntil.Completed, "", ""); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_DeployProject_AllParameters_Async() + public void Example_QuestionAnsweringProjects_DeployProject_AllParameters() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); - Operation operation = await client.DeployProjectAsync(WaitUntil.Completed, "", ""); - BinaryData responseData = operation.Value; + Operation operation = client.DeployProject(WaitUntil.Completed, "", ""); + } - JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("deploymentName").ToString()); - Console.WriteLine(result.GetProperty("lastDeployedDateTime").ToString()); + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnsweringProjects_DeployProject_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); + + Operation operation = await client.DeployProjectAsync(WaitUntil.Completed, "", ""); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_UpdateSources_ShortVersion() + public void Example_QuestionAnsweringProjects_UpdateSources_ShortVersion() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object[] { @@ -1826,28 +2617,22 @@ public void Example_UpdateSources_ShortVersion() op = "add", value = new { +source = "", sourceUri = "http://localhost:3000", sourceKind = "file", }, } }); - Operation> operation = client.UpdateSources(WaitUntil.Completed, "", content); - Pageable responseData = operation.Value; - foreach (BinaryData item in operation.Value) - { - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("sourceUri").ToString()); - Console.WriteLine(result.GetProperty("sourceKind").ToString()); - } + Operation operation = client.UpdateSources(WaitUntil.Completed, "", content); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_UpdateSources_ShortVersion_Async() + public async Task Example_QuestionAnsweringProjects_UpdateSources_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object[] { @@ -1856,28 +2641,22 @@ public async Task Example_UpdateSources_ShortVersion_Async() op = "add", value = new { +source = "", sourceUri = "http://localhost:3000", sourceKind = "file", }, } }); - Operation> operation = await client.UpdateSourcesAsync(WaitUntil.Completed, "", content); - AsyncPageable responseData = operation.Value; - await foreach (BinaryData item in operation.Value) - { - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("sourceUri").ToString()); - Console.WriteLine(result.GetProperty("sourceKind").ToString()); - } + Operation operation = await client.UpdateSourcesAsync(WaitUntil.Completed, "", content); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_UpdateSources_AllParameters() + public void Example_QuestionAnsweringProjects_UpdateSources_AllParameters() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object[] { @@ -1886,36 +2665,25 @@ public void Example_UpdateSources_AllParameters() op = "add", value = new { -refresh = true, displayName = "", source = "", sourceUri = "http://localhost:3000", sourceKind = "file", contentStructureKind = "unstructured", +refresh = true, }, } }); - Operation> operation = client.UpdateSources(WaitUntil.Completed, "", content); - Pageable responseData = operation.Value; - foreach (BinaryData item in operation.Value) - { - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("displayName").ToString()); - Console.WriteLine(result.GetProperty("source").ToString()); - Console.WriteLine(result.GetProperty("sourceUri").ToString()); - Console.WriteLine(result.GetProperty("sourceKind").ToString()); - Console.WriteLine(result.GetProperty("contentStructureKind").ToString()); - } + Operation operation = client.UpdateSources(WaitUntil.Completed, "", content); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_UpdateSources_AllParameters_Async() + public async Task Example_QuestionAnsweringProjects_UpdateSources_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object[] { @@ -1924,36 +2692,25 @@ public async Task Example_UpdateSources_AllParameters_Async() op = "add", value = new { -refresh = true, displayName = "", source = "", sourceUri = "http://localhost:3000", sourceKind = "file", contentStructureKind = "unstructured", +refresh = true, }, } }); - Operation> operation = await client.UpdateSourcesAsync(WaitUntil.Completed, "", content); - AsyncPageable responseData = operation.Value; - await foreach (BinaryData item in operation.Value) - { - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("displayName").ToString()); - Console.WriteLine(result.GetProperty("source").ToString()); - Console.WriteLine(result.GetProperty("sourceUri").ToString()); - Console.WriteLine(result.GetProperty("sourceKind").ToString()); - Console.WriteLine(result.GetProperty("contentStructureKind").ToString()); - } + Operation operation = await client.UpdateSourcesAsync(WaitUntil.Completed, "", content); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_UpdateQnas_ShortVersion() + public void Example_QuestionAnsweringProjects_UpdateQnas_ShortVersion() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object[] { @@ -1963,22 +2720,16 @@ public void Example_UpdateQnas_ShortVersion() value = new object(), } }); - Operation> operation = client.UpdateQnas(WaitUntil.Completed, "", content); - Pageable responseData = operation.Value; - foreach (BinaryData item in operation.Value) - { - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.ToString()); - } + Operation operation = client.UpdateQnas(WaitUntil.Completed, "", content); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_UpdateQnas_ShortVersion_Async() + public async Task Example_QuestionAnsweringProjects_UpdateQnas_ShortVersion_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object[] { @@ -1988,22 +2739,16 @@ public async Task Example_UpdateQnas_ShortVersion_Async() value = new object(), } }); - Operation> operation = await client.UpdateQnasAsync(WaitUntil.Completed, "", content); - AsyncPageable responseData = operation.Value; - await foreach (BinaryData item in operation.Value) - { - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.ToString()); - } + Operation operation = await client.UpdateQnasAsync(WaitUntil.Completed, "", content); } [Test] [Ignore("Only validating compilation of examples")] - public void Example_UpdateQnas_AllParameters() + public void Example_QuestionAnsweringProjects_UpdateQnas_AllParameters() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object[] { @@ -2012,7 +2757,6 @@ public void Example_UpdateQnas_AllParameters() op = "add", value = new { -id = 1234, answer = "", source = "", questions = new object[] @@ -2055,44 +2799,16 @@ public void Example_UpdateQnas_AllParameters() }, } }); - Operation> operation = client.UpdateQnas(WaitUntil.Completed, "", content); - Pageable responseData = operation.Value; - foreach (BinaryData item in operation.Value) - { - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("id").ToString()); - Console.WriteLine(result.GetProperty("answer").ToString()); - Console.WriteLine(result.GetProperty("source").ToString()); - Console.WriteLine(result.GetProperty("questions")[0].ToString()); - Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("isContextOnly").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("displayOrder").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qnaId").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("id").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("answer").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("source").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("questions")[0].ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("metadata").GetProperty("").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("activeLearningSuggestions")[0].GetProperty("clusterHead").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("question").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("userSuggestedCount").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("autoSuggestedCount").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("displayText").ToString()); - Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("clusterHead").ToString()); - Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("question").ToString()); - Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("userSuggestedCount").ToString()); - Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("autoSuggestedCount").ToString()); - } + Operation operation = client.UpdateQnas(WaitUntil.Completed, "", content); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Example_UpdateQnas_AllParameters_Async() + public async Task Example_QuestionAnsweringProjects_UpdateQnas_AllParameters_Async() { Uri endpoint = new Uri(""); AzureKeyCredential credential = new AzureKeyCredential(""); - QuestionAnsweringAuthoringClient client = new QuestionAnsweringAuthoringClient(endpoint, credential); + QuestionAnsweringProjects client = new AuthoringClient(endpoint, credential).GetQuestionAnsweringProjectsClient(apiVersion: "2023-04-01"); using RequestContent content = RequestContent.Create(new object[] { @@ -2101,7 +2817,6 @@ public async Task Example_UpdateQnas_AllParameters_Async() op = "add", value = new { -id = 1234, answer = "", source = "", questions = new object[] @@ -2144,35 +2859,7 @@ public async Task Example_UpdateQnas_AllParameters_Async() }, } }); - Operation> operation = await client.UpdateQnasAsync(WaitUntil.Completed, "", content); - AsyncPageable responseData = operation.Value; - await foreach (BinaryData item in operation.Value) - { - JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; - Console.WriteLine(result.GetProperty("lastUpdatedDateTime").ToString()); - Console.WriteLine(result.GetProperty("id").ToString()); - Console.WriteLine(result.GetProperty("answer").ToString()); - Console.WriteLine(result.GetProperty("source").ToString()); - Console.WriteLine(result.GetProperty("questions")[0].ToString()); - Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("isContextOnly").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("displayOrder").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qnaId").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("id").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("answer").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("source").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("questions")[0].ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("metadata").GetProperty("").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("activeLearningSuggestions")[0].GetProperty("clusterHead").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("question").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("userSuggestedCount").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qna").GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("autoSuggestedCount").ToString()); - Console.WriteLine(result.GetProperty("dialog").GetProperty("prompts")[0].GetProperty("displayText").ToString()); - Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("clusterHead").ToString()); - Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("question").ToString()); - Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("userSuggestedCount").ToString()); - Console.WriteLine(result.GetProperty("activeLearningSuggestions")[0].GetProperty("suggestedQuestions")[0].GetProperty("autoSuggestedCount").ToString()); - } + Operation operation = await client.UpdateQnasAsync(WaitUntil.Completed, "", content); } } } diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/tsp-location.yaml b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/tsp-location.yaml new file mode 100644 index 000000000000..2a403c948c2c --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Authoring/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/cognitiveservices/Language.QuestionAnswering-authoring +commit: 84a9f8854055b954cb9544fa06b3d5713f414ea1 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswerSpan.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswerSpan.Serialization.cs new file mode 100644 index 000000000000..47adf55e504e --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswerSpan.Serialization.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering +{ + public partial class AnswerSpan : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AnswerSpan)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (Optional.IsDefined(Confidence)) + { + writer.WritePropertyName("confidenceScore"u8); + writer.WriteNumberValue(Confidence.Value); + } + if (Optional.IsDefined(Offset)) + { + writer.WritePropertyName("offset"u8); + writer.WriteNumberValue(Offset.Value); + } + if (Optional.IsDefined(Length)) + { + writer.WritePropertyName("length"u8); + writer.WriteNumberValue(Length.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AnswerSpan IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AnswerSpan)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAnswerSpan(document.RootElement, options); + } + + internal static AnswerSpan DeserializeAnswerSpan(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string text = default; + double? confidenceScore = default; + int? offset = default; + int? length = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("confidenceScore"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + confidenceScore = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("offset"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + offset = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("length"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + length = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AnswerSpan(text, confidenceScore, offset, length, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AnswerSpan)} does not support writing '{options.Format}' format."); + } + } + + AnswerSpan IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAnswerSpan(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AnswerSpan)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static AnswerSpan FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAnswerSpan(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswerSpan.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswerSpan.cs new file mode 100644 index 000000000000..3433d174984d --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswerSpan.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering +{ + /// Answer span object of QnA. + public partial class AnswerSpan + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal AnswerSpan() + { + } + + /// Initializes a new instance of . + /// Predicted text of answer span. + /// Predicted score of answer span, value ranges from 0 to 1. + /// The answer span offset from the start of answer. + /// The length of the answer span. + /// Keeps track of any properties unknown to the library. + internal AnswerSpan(string text, double? confidence, int? offset, int? length, IDictionary serializedAdditionalRawData) + { + Text = text; + Confidence = confidence; + Offset = offset; + Length = length; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Predicted text of answer span. + public string Text { get; } + /// Predicted score of answer span, value ranges from 0 to 1. + public double? Confidence { get; } + /// The answer span offset from the start of answer. + public int? Offset { get; } + /// The length of the answer span. + public int? Length { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersFromTextOptions.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersFromTextOptions.Serialization.cs new file mode 100644 index 000000000000..0510d15583b6 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersFromTextOptions.Serialization.cs @@ -0,0 +1,186 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering +{ + public partial class AnswersFromTextOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AnswersFromTextOptions)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("question"u8); + writer.WriteStringValue(Question); + writer.WritePropertyName("records"u8); + writer.WriteStartArray(); + foreach (var item in TextDocuments) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(Language)) + { + writer.WritePropertyName("language"u8); + writer.WriteStringValue(Language); + } + if (Optional.IsDefined(StringIndexType)) + { + writer.WritePropertyName("stringIndexType"u8); + writer.WriteStringValue(StringIndexType.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AnswersFromTextOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AnswersFromTextOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAnswersFromTextOptions(document.RootElement, options); + } + + internal static AnswersFromTextOptions DeserializeAnswersFromTextOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string question = default; + IList records = default; + string language = default; + StringIndexType? stringIndexType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("question"u8)) + { + question = property.Value.GetString(); + continue; + } + if (property.NameEquals("records"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TextDocument.DeserializeTextDocument(item, options)); + } + records = array; + continue; + } + if (property.NameEquals("language"u8)) + { + language = property.Value.GetString(); + continue; + } + if (property.NameEquals("stringIndexType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + stringIndexType = new StringIndexType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AnswersFromTextOptions(question, records, language, stringIndexType, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AnswersFromTextOptions)} does not support writing '{options.Format}' format."); + } + } + + AnswersFromTextOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAnswersFromTextOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AnswersFromTextOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static AnswersFromTextOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAnswersFromTextOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersFromTextOptions.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersFromTextOptions.cs new file mode 100644 index 000000000000..7ea470e5432c --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersFromTextOptions.cs @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Language.QuestionAnswering +{ + /// The question and text record parameters to answer. + public partial class AnswersFromTextOptions + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// User question to query against the given text records. + /// Text records to be searched for given question. + /// or is null. + public AnswersFromTextOptions(string question, IEnumerable textDocuments) + { + Argument.AssertNotNull(question, nameof(question)); + Argument.AssertNotNull(textDocuments, nameof(textDocuments)); + + Question = question; + TextDocuments = textDocuments.ToList(); + } + + /// Initializes a new instance of . + /// User question to query against the given text records. + /// Text records to be searched for given question. + /// + /// Language of the text records. This is BCP-47 representation of a language. For + /// example, use "en" for English; "es" for Spanish etc. If not set, use "en" for + /// English as default. + /// + /// + /// Specifies the method used to interpret string offsets. Defaults to Text + /// Elements (Graphemes) according to Unicode v8.0.0. For additional information + /// see https://aka.ms/text-analytics-offsets. + /// + /// Keeps track of any properties unknown to the library. + internal AnswersFromTextOptions(string question, IList textDocuments, string language, StringIndexType? stringIndexType, IDictionary serializedAdditionalRawData) + { + Question = question; + TextDocuments = textDocuments; + Language = language; + StringIndexType = stringIndexType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AnswersFromTextOptions() + { + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersFromTextResult.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersFromTextResult.Serialization.cs new file mode 100644 index 000000000000..de3e0e2bba36 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersFromTextResult.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering +{ + public partial class AnswersFromTextResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AnswersFromTextResult)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Answers)) + { + writer.WritePropertyName("answers"u8); + writer.WriteStartArray(); + foreach (var item in Answers) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AnswersFromTextResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AnswersFromTextResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAnswersFromTextResult(document.RootElement, options); + } + + internal static AnswersFromTextResult DeserializeAnswersFromTextResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList answers = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("answers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TextAnswer.DeserializeTextAnswer(item, options)); + } + answers = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AnswersFromTextResult(answers ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AnswersFromTextResult)} does not support writing '{options.Format}' format."); + } + } + + AnswersFromTextResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAnswersFromTextResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AnswersFromTextResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static AnswersFromTextResult FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAnswersFromTextResult(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersFromTextResult.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersFromTextResult.cs new file mode 100644 index 000000000000..2b60f352dada --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersFromTextResult.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering +{ + /// Represents the answer results. + public partial class AnswersFromTextResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal AnswersFromTextResult() + { + Answers = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Represents the answer results. + /// Keeps track of any properties unknown to the library. + internal AnswersFromTextResult(IReadOnlyList answers, IDictionary serializedAdditionalRawData) + { + Answers = answers; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Represents the answer results. + public IReadOnlyList Answers { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersOptions.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersOptions.Serialization.cs new file mode 100644 index 000000000000..0d3e9e9df135 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersOptions.Serialization.cs @@ -0,0 +1,287 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering +{ + public partial class AnswersOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AnswersOptions)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(QnaId)) + { + writer.WritePropertyName("qnaId"u8); + writer.WriteNumberValue(QnaId.Value); + } + if (Optional.IsDefined(Question)) + { + writer.WritePropertyName("question"u8); + writer.WriteStringValue(Question); + } + if (Optional.IsDefined(Size)) + { + writer.WritePropertyName("top"u8); + writer.WriteNumberValue(Size.Value); + } + if (Optional.IsDefined(UserId)) + { + writer.WritePropertyName("userId"u8); + writer.WriteStringValue(UserId); + } + if (Optional.IsDefined(ConfidenceThreshold)) + { + writer.WritePropertyName("confidenceScoreThreshold"u8); + writer.WriteNumberValue(ConfidenceThreshold.Value); + } + if (Optional.IsDefined(AnswerContext)) + { + writer.WritePropertyName("context"u8); + writer.WriteObjectValue(AnswerContext, options); + } + if (Optional.IsDefined(RankerKind)) + { + writer.WritePropertyName("rankerType"u8); + writer.WriteStringValue(RankerKind.Value.ToString()); + } + if (Optional.IsDefined(Filters)) + { + writer.WritePropertyName("filters"u8); + writer.WriteObjectValue(Filters, options); + } + if (Optional.IsDefined(ShortAnswerOptions)) + { + writer.WritePropertyName("answerSpanRequest"u8); + writer.WriteObjectValue(ShortAnswerOptions, options); + } + if (Optional.IsDefined(IncludeUnstructuredSources)) + { + writer.WritePropertyName("includeUnstructuredSources"u8); + writer.WriteBooleanValue(IncludeUnstructuredSources.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AnswersOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AnswersOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAnswersOptions(document.RootElement, options); + } + + internal static AnswersOptions DeserializeAnswersOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? qnaId = default; + string question = default; + int? top = default; + string userId = default; + double? confidenceScoreThreshold = default; + KnowledgeBaseAnswerContext context = default; + RankerKind? rankerType = default; + QueryFilters filters = default; + ShortAnswerOptions answerSpanRequest = default; + bool? includeUnstructuredSources = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("qnaId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + qnaId = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("question"u8)) + { + question = property.Value.GetString(); + continue; + } + if (property.NameEquals("top"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + top = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("userId"u8)) + { + userId = property.Value.GetString(); + continue; + } + if (property.NameEquals("confidenceScoreThreshold"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + confidenceScoreThreshold = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("context"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + context = KnowledgeBaseAnswerContext.DeserializeKnowledgeBaseAnswerContext(property.Value, options); + continue; + } + if (property.NameEquals("rankerType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + rankerType = new RankerKind(property.Value.GetString()); + continue; + } + if (property.NameEquals("filters"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + filters = QueryFilters.DeserializeQueryFilters(property.Value, options); + continue; + } + if (property.NameEquals("answerSpanRequest"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + answerSpanRequest = ShortAnswerOptions.DeserializeShortAnswerOptions(property.Value, options); + continue; + } + if (property.NameEquals("includeUnstructuredSources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + includeUnstructuredSources = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AnswersOptions( + qnaId, + question, + top, + userId, + confidenceScoreThreshold, + context, + rankerType, + filters, + answerSpanRequest, + includeUnstructuredSources, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AnswersOptions)} does not support writing '{options.Format}' format."); + } + } + + AnswersOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAnswersOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AnswersOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static AnswersOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAnswersOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersOptions.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersOptions.cs similarity index 62% rename from sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersOptions.cs rename to sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersOptions.cs index d1645a09e359..68ee9179af42 100644 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersOptions.cs +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersOptions.cs @@ -5,18 +5,56 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.AI.Language.QuestionAnswering { /// Parameters to query a knowledge base. public partial class AnswersOptions { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . public AnswersOptions() { } /// Initializes a new instance of . - /// Exact QnA ID to fetch from the knowledge base, this field takes priority over question. + /// + /// Exact QnA ID to fetch from the knowledge base, this field takes priority over + /// question. + /// /// User question to query against the knowledge base. /// Max number of answers to be returned for the question. /// Unique identifier for the user. @@ -26,7 +64,8 @@ public AnswersOptions() /// Filter QnAs based on given metadata list and knowledge base sources. /// To configure Answer span prediction feature. /// (Optional) Flag to enable Query over Unstructured Sources. - internal AnswersOptions(int? qnaId, string question, int? size, string userId, double? confidenceThreshold, KnowledgeBaseAnswerContext answerContext, RankerKind? rankerKind, QueryFilters filters, ShortAnswerOptions shortAnswerOptions, bool? includeUnstructuredSources) + /// Keeps track of any properties unknown to the library. + internal AnswersOptions(int? qnaId, string question, int? size, string userId, double? confidenceThreshold, KnowledgeBaseAnswerContext answerContext, RankerKind? rankerKind, QueryFilters filters, ShortAnswerOptions shortAnswerOptions, bool? includeUnstructuredSources, IDictionary serializedAdditionalRawData) { QnaId = qnaId; Question = question; @@ -38,6 +77,7 @@ internal AnswersOptions(int? qnaId, string question, int? size, string userId, d Filters = filters; ShortAnswerOptions = shortAnswerOptions; IncludeUnstructuredSources = includeUnstructuredSources; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Unique identifier for the user. public string UserId { get; set; } diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersResult.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersResult.Serialization.cs new file mode 100644 index 000000000000..5701aaaba462 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersResult.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering +{ + public partial class AnswersResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AnswersResult)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Answers)) + { + writer.WritePropertyName("answers"u8); + writer.WriteStartArray(); + foreach (var item in Answers) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AnswersResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AnswersResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAnswersResult(document.RootElement, options); + } + + internal static AnswersResult DeserializeAnswersResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList answers = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("answers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(KnowledgeBaseAnswer.DeserializeKnowledgeBaseAnswer(item, options)); + } + answers = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AnswersResult(answers ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AnswersResult)} does not support writing '{options.Format}' format."); + } + } + + AnswersResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAnswersResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AnswersResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static AnswersResult FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAnswersResult(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersResult.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersResult.cs new file mode 100644 index 000000000000..9dcf665bff03 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/AnswersResult.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering +{ + /// Represents List of Question Answers. + public partial class AnswersResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal AnswersResult() + { + Answers = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Represents Answer Result list. + /// Keeps track of any properties unknown to the library. + internal AnswersResult(IReadOnlyList answers, IDictionary serializedAdditionalRawData) + { + Answers = answers; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Represents Answer Result list. + public IReadOnlyList Answers { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Docs/QuestionAnswering.xml b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Docs/QuestionAnswering.xml new file mode 100644 index 000000000000..d93fe922584a --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Docs/QuestionAnswering.xml @@ -0,0 +1,437 @@ + + + + + +This sample shows how to call GetAnswersAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + +AnswersOptions knowledgeBaseQueryOptions = new AnswersOptions(); +Response response = await client.GetAnswersAsync("", "", knowledgeBaseQueryOptions); +]]> +This sample shows how to call GetAnswersAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + +AnswersOptions knowledgeBaseQueryOptions = new AnswersOptions +{ + Size = 1234, + UserId = "", + ConfidenceThreshold = 123.45, + AnswerContext = new KnowledgeBaseAnswerContext(1234) + { + PreviousQuestion = "", + }, + RankerKind = RankerKind.QuestionOnly, + Filters = new QueryFilters + { + MetadataFilter = new MetadataFilter + { + Metadata = { new MetadataRecord("", "") }, + LogicalOperation = LogicalOperationKind.And, + }, + SourceFilter = { "" }, + LogicalOperation = LogicalOperationKind.And, + }, + ShortAnswerOptions = new ShortAnswerOptions + { + ConfidenceThreshold = 123.45, + Size = 1234, + }, + IncludeUnstructuredSources = true, +}; +Response response = await client.GetAnswersAsync("", "", knowledgeBaseQueryOptions); +]]> + + + +This sample shows how to call GetAnswers. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + +AnswersOptions knowledgeBaseQueryOptions = new AnswersOptions(); +Response response = client.GetAnswers("", "", knowledgeBaseQueryOptions); +]]> +This sample shows how to call GetAnswers with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + +AnswersOptions knowledgeBaseQueryOptions = new AnswersOptions +{ + Size = 1234, + UserId = "", + ConfidenceThreshold = 123.45, + AnswerContext = new KnowledgeBaseAnswerContext(1234) + { + PreviousQuestion = "", + }, + RankerKind = RankerKind.QuestionOnly, + Filters = new QueryFilters + { + MetadataFilter = new MetadataFilter + { + Metadata = { new MetadataRecord("", "") }, + LogicalOperation = LogicalOperationKind.And, + }, + SourceFilter = { "" }, + LogicalOperation = LogicalOperationKind.And, + }, + ShortAnswerOptions = new ShortAnswerOptions + { + ConfidenceThreshold = 123.45, + Size = 1234, + }, + IncludeUnstructuredSources = true, +}; +Response response = client.GetAnswers("", "", knowledgeBaseQueryOptions); +]]> + + + +This sample shows how to call GetAnswersAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + +using RequestContent content = RequestContent.Create(new object()); +Response response = await client.GetAnswersAsync("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call GetAnswersAsync with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + +using RequestContent content = RequestContent.Create(new +{ + qnaId = 1234, + question = "", + top = 1234, + userId = "", + confidenceScoreThreshold = 123.45, + context = new + { + previousQnaId = 1234, + previousUserQuery = "", + }, + rankerType = "QuestionOnly", + filters = new + { + metadataFilter = new + { + metadata = new object[] + { + new + { + key = "", + value = "", + } + }, + logicalOperation = "AND", + }, + sourceFilter = new object[] + { + "" + }, + logicalOperation = "AND", + }, + answerSpanRequest = new + { + enable = true, + confidenceScoreThreshold = 123.45, + topAnswersWithSpan = 1234, + }, + includeUnstructuredSources = true, +}); +Response response = await client.GetAnswersAsync("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("questions")[0].ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answer").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("confidenceScore").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("source").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("metadata").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("dialog").GetProperty("isContextOnly").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("dialog").GetProperty("prompts")[0].GetProperty("displayOrder").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qnaId").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("dialog").GetProperty("prompts")[0].GetProperty("displayText").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("text").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("confidenceScore").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("offset").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("length").ToString()); +]]> + + + +This sample shows how to call GetAnswers and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + +using RequestContent content = RequestContent.Create(new object()); +Response response = client.GetAnswers("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call GetAnswers with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + +using RequestContent content = RequestContent.Create(new +{ + qnaId = 1234, + question = "", + top = 1234, + userId = "", + confidenceScoreThreshold = 123.45, + context = new + { + previousQnaId = 1234, + previousUserQuery = "", + }, + rankerType = "QuestionOnly", + filters = new + { + metadataFilter = new + { + metadata = new object[] + { + new + { + key = "", + value = "", + } + }, + logicalOperation = "AND", + }, + sourceFilter = new object[] + { + "" + }, + logicalOperation = "AND", + }, + answerSpanRequest = new + { + enable = true, + confidenceScoreThreshold = 123.45, + topAnswersWithSpan = 1234, + }, + includeUnstructuredSources = true, +}); +Response response = client.GetAnswers("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("questions")[0].ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answer").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("confidenceScore").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("source").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("metadata").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("dialog").GetProperty("isContextOnly").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("dialog").GetProperty("prompts")[0].GetProperty("displayOrder").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qnaId").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("dialog").GetProperty("prompts")[0].GetProperty("displayText").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("text").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("confidenceScore").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("offset").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("length").ToString()); +]]> + + + +This sample shows how to call GetAnswersFromTextAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + +AnswersFromTextOptions textQueryOptions = new AnswersFromTextOptions("", new TextDocument[] +{ + new TextDocument("", "") +}); +Response response = await client.GetAnswersFromTextAsync(textQueryOptions); +]]> +This sample shows how to call GetAnswersFromTextAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + +AnswersFromTextOptions textQueryOptions = new AnswersFromTextOptions("", new TextDocument[] +{ + new TextDocument("", "") +}) +{ + Language = "", +}; +Response response = await client.GetAnswersFromTextAsync(textQueryOptions); +]]> + + + +This sample shows how to call GetAnswersFromText. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + +AnswersFromTextOptions textQueryOptions = new AnswersFromTextOptions("", new TextDocument[] +{ + new TextDocument("", "") +}); +Response response = client.GetAnswersFromText(textQueryOptions); +]]> +This sample shows how to call GetAnswersFromText with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + +AnswersFromTextOptions textQueryOptions = new AnswersFromTextOptions("", new TextDocument[] +{ + new TextDocument("", "") +}) +{ + Language = "", +}; +Response response = client.GetAnswersFromText(textQueryOptions); +]]> + + + +This sample shows how to call GetAnswersFromTextAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + +using RequestContent content = RequestContent.Create(new +{ + question = "", + records = new object[] + { + new + { + id = "", + text = "", + } + }, +}); +Response response = await client.GetAnswersFromTextAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call GetAnswersFromTextAsync with all request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + +using RequestContent content = RequestContent.Create(new +{ + question = "", + records = new object[] + { + new + { + id = "", + text = "", + } + }, + language = "", + stringIndexType = "TextElements_v8", +}); +Response response = await client.GetAnswersFromTextAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answer").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("confidenceScore").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("text").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("confidenceScore").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("offset").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("length").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("offset").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("length").ToString()); +]]> + + + +This sample shows how to call GetAnswersFromText and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + +using RequestContent content = RequestContent.Create(new +{ + question = "", + records = new object[] + { + new + { + id = "", + text = "", + } + }, +}); +Response response = client.GetAnswersFromText(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call GetAnswersFromText with all request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + +using RequestContent content = RequestContent.Create(new +{ + question = "", + records = new object[] + { + new + { + id = "", + text = "", + } + }, + language = "", + stringIndexType = "TextElements_v8", +}); +Response response = client.GetAnswersFromText(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answer").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("confidenceScore").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("text").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("confidenceScore").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("offset").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("length").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("offset").ToString()); +Console.WriteLine(result.GetProperty("answers")[0].GetProperty("length").ToString()); +]]> + + + \ No newline at end of file diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Internal/ModelSerializationExtensions.cs index ee743f35f739..ce6d47a6be82 100644 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Internal/ModelSerializationExtensions.cs @@ -168,13 +168,16 @@ public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset v writer.WriteNumberValue(value.ToUnixTimeSeconds()); } - public static void WriteObjectValue(this Utf8JsonWriter writer, T value) + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) { switch (value) { case null: writer.WriteNullValue(); break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; case IUtf8JsonSerializable serializable: serializable.Write(writer); break; @@ -229,7 +232,7 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, T value) foreach (var pair in enumerable) { writer.WritePropertyName(pair.Key); - writer.WriteObjectValue(pair.Value); + writer.WriteObjectValue(pair.Value, options); } writer.WriteEndObject(); break; @@ -237,7 +240,7 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, T value) writer.WriteStartArray(); foreach (var item in objectEnumerable) { - writer.WriteObjectValue(item); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); break; @@ -249,9 +252,9 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, T value) } } - public static void WriteObjectValue(this Utf8JsonWriter writer, object value) + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) { - writer.WriteObjectValue(value); + writer.WriteObjectValue(value, options); } internal static class TypeFormatters diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Internal/MultipartFormDataRequestContent.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Internal/MultipartFormDataRequestContent.cs deleted file mode 100644 index 2086f68ff2d0..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Internal/MultipartFormDataRequestContent.cs +++ /dev/null @@ -1,203 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Globalization; -using System.IO; -using System.Net.Http; -using System.Net.Http.Headers; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.Pipeline; - -namespace Azure.AI.Language.QuestionAnswering -{ - internal class MultipartFormDataRequestContent : RequestContent - { - private readonly System.Net.Http.MultipartFormDataContent _multipartContent; - private static readonly Random _random = new Random(); - private static readonly char[] _boundaryValues = "0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".ToCharArray(); - - public MultipartFormDataRequestContent() - { - _multipartContent = new System.Net.Http.MultipartFormDataContent(CreateBoundary()); - } - - public string ContentType - { - get - { - return _multipartContent.Headers.ContentType.ToString(); - } - } - - internal HttpContent HttpContent => _multipartContent; - - private static string CreateBoundary() - { - Span chars = new char[70]; - byte[] random = new byte[70]; - _random.NextBytes(random); - int mask = 255 >> 2; - for (int i = 0; i < 70; i++) - { - chars[i] = _boundaryValues[random[i] & mask]; - } - return chars.ToString(); - } - - public void Add(string content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - Add(new StringContent(content), name, filename, contentType); - } - - public void Add(int content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - string value = content.ToString("G", CultureInfo.InvariantCulture); - Add(new StringContent(value), name, filename, contentType); - } - - public void Add(long content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - string value = content.ToString("G", CultureInfo.InvariantCulture); - Add(new StringContent(value), name, filename, contentType); - } - - public void Add(float content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - string value = content.ToString("G", CultureInfo.InvariantCulture); - Add(new StringContent(value), name, filename, contentType); - } - - public void Add(double content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - string value = content.ToString("G", CultureInfo.InvariantCulture); - Add(new StringContent(value), name, filename, contentType); - } - - public void Add(decimal content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - string value = content.ToString("G", CultureInfo.InvariantCulture); - Add(new StringContent(value), name, filename, contentType); - } - - public void Add(bool content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - string value = content ? "true" : "false"; - Add(new StringContent(value), name, filename, contentType); - } - - public void Add(Stream content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - Add(new StreamContent(content), name, filename, contentType); - } - - public void Add(byte[] content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - Add(new ByteArrayContent(content), name, filename, contentType); - } - - public void Add(BinaryData content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - Add(new ByteArrayContent(content.ToArray()), name, filename, contentType); - } - - private void Add(HttpContent content, string name, string filename, string contentType) - { - if (filename != null) - { - Argument.AssertNotNullOrEmpty(filename, nameof(filename)); - AddFilenameHeader(content, name, filename); - } - if (contentType != null) - { - Argument.AssertNotNullOrEmpty(contentType, nameof(contentType)); - AddContentTypeHeader(content, contentType); - } - _multipartContent.Add(content, name); - } - - public static void AddFilenameHeader(HttpContent content, string name, string filename) - { - ContentDispositionHeaderValue header = new ContentDispositionHeaderValue("form-data") { Name = name, FileName = filename }; - content.Headers.ContentDisposition = header; - } - - public static void AddContentTypeHeader(HttpContent content, string contentType) - { - MediaTypeHeaderValue header = new MediaTypeHeaderValue(contentType); - content.Headers.ContentType = header; - } - - public override bool TryComputeLength(out long length) - { - if (_multipartContent.Headers.ContentLength is long contentLength) - { - length = contentLength; - return true; - } - length = 0; - return false; - } - - public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) - { -#if NET6_0_OR_GREATER - _multipartContent.CopyTo(stream, default, cancellationToken); -#else -#pragma warning disable AZC0107 - _multipartContent.CopyToAsync(stream).EnsureCompleted(); -#pragma warning restore AZC0107 -#endif - } - - public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) - { -#if NET6_0_OR_GREATER - await _multipartContent.CopyToAsync(stream, cancellationToken).ConfigureAwait(false); -#else - await _multipartContent.CopyToAsync(stream).ConfigureAwait(false); -#endif - } - - public override void Dispose() - { - _multipartContent.Dispose(); - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Internal/RequestContentHelper.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Internal/RequestContentHelper.cs deleted file mode 100644 index 12f6fb731b21..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Internal/RequestContentHelper.cs +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Language.QuestionAnswering -{ - internal static class RequestContentHelper - { - public static RequestContent FromEnumerable(IEnumerable enumerable) - where T : notnull - { - Utf8JsonRequestContent content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteStartArray(); - foreach (var item in enumerable) - { - content.JsonWriter.WriteObjectValue(item); - } - content.JsonWriter.WriteEndArray(); - - return content; - } - - public static RequestContent FromEnumerable(IEnumerable enumerable) - { - Utf8JsonRequestContent content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteStartArray(); - foreach (var item in enumerable) - { - if (item == null) - { - content.JsonWriter.WriteNullValue(); - } - else - { -#if NET6_0_OR_GREATER - content.JsonWriter.WriteRawValue(item); -#else - using (JsonDocument document = JsonDocument.Parse(item, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(content.JsonWriter, document.RootElement); - } -#endif - } - } - content.JsonWriter.WriteEndArray(); - - return content; - } - - public static RequestContent FromEnumerable(ReadOnlySpan span) - where T : notnull - { - Utf8JsonRequestContent content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteStartArray(); - for (int i = 0; i < span.Length; i++) - { - content.JsonWriter.WriteObjectValue(span[i]); - } - content.JsonWriter.WriteEndArray(); - - return content; - } - - public static RequestContent FromDictionary(IDictionary dictionary) - where TValue : notnull - { - Utf8JsonRequestContent content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteStartObject(); - foreach (var item in dictionary) - { - content.JsonWriter.WritePropertyName(item.Key); - content.JsonWriter.WriteObjectValue(item.Value); - } - content.JsonWriter.WriteEndObject(); - - return content; - } - - public static RequestContent FromDictionary(IDictionary dictionary) - { - Utf8JsonRequestContent content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteStartObject(); - foreach (var item in dictionary) - { - content.JsonWriter.WritePropertyName(item.Key); - if (item.Value == null) - { - content.JsonWriter.WriteNullValue(); - } - else - { -#if NET6_0_OR_GREATER - content.JsonWriter.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(content.JsonWriter, document.RootElement); - } -#endif - } - } - content.JsonWriter.WriteEndObject(); - - return content; - } - - public static RequestContent FromObject(object value) - { - Utf8JsonRequestContent content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(value); - return content; - } - - public static RequestContent FromObject(BinaryData value) - { - Utf8JsonRequestContent content = new Utf8JsonRequestContent(); -#if NET6_0_OR_GREATER - content.JsonWriter.WriteRawValue(value); -#else - using (JsonDocument document = JsonDocument.Parse(value, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(content.JsonWriter, document.RootElement); - } -#endif - return content; - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswer.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswer.Serialization.cs new file mode 100644 index 000000000000..d2eb4982f181 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswer.Serialization.cs @@ -0,0 +1,276 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering +{ + public partial class KnowledgeBaseAnswer : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KnowledgeBaseAnswer)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Questions)) + { + writer.WritePropertyName("questions"u8); + writer.WriteStartArray(); + foreach (var item in Questions) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Answer)) + { + writer.WritePropertyName("answer"u8); + writer.WriteStringValue(Answer); + } + if (Optional.IsDefined(Confidence)) + { + writer.WritePropertyName("confidenceScore"u8); + writer.WriteNumberValue(Confidence.Value); + } + if (Optional.IsDefined(QnaId)) + { + writer.WritePropertyName("id"u8); + writer.WriteNumberValue(QnaId.Value); + } + if (Optional.IsDefined(Source)) + { + writer.WritePropertyName("source"u8); + writer.WriteStringValue(Source); + } + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Dialog)) + { + writer.WritePropertyName("dialog"u8); + writer.WriteObjectValue(Dialog, options); + } + if (Optional.IsDefined(ShortAnswer)) + { + writer.WritePropertyName("answerSpan"u8); + writer.WriteObjectValue(ShortAnswer, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + KnowledgeBaseAnswer IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KnowledgeBaseAnswer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeBaseAnswer(document.RootElement, options); + } + + internal static KnowledgeBaseAnswer DeserializeKnowledgeBaseAnswer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList questions = default; + string answer = default; + double? confidenceScore = default; + int? id = default; + string source = default; + IReadOnlyDictionary metadata = default; + KnowledgeBaseAnswerDialog dialog = default; + AnswerSpan answerSpan = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("questions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + questions = array; + continue; + } + if (property.NameEquals("answer"u8)) + { + answer = property.Value.GetString(); + continue; + } + if (property.NameEquals("confidenceScore"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + confidenceScore = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("id"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("source"u8)) + { + source = property.Value.GetString(); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (property.NameEquals("dialog"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dialog = KnowledgeBaseAnswerDialog.DeserializeKnowledgeBaseAnswerDialog(property.Value, options); + continue; + } + if (property.NameEquals("answerSpan"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + answerSpan = AnswerSpan.DeserializeAnswerSpan(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeBaseAnswer( + questions ?? new ChangeTrackingList(), + answer, + confidenceScore, + id, + source, + metadata ?? new ChangeTrackingDictionary(), + dialog, + answerSpan, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(KnowledgeBaseAnswer)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeBaseAnswer IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeKnowledgeBaseAnswer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeBaseAnswer)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static KnowledgeBaseAnswer FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeKnowledgeBaseAnswer(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswer.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswer.cs similarity index 56% rename from sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswer.cs rename to sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswer.cs index c413f63a680b..030993354a5d 100644 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswer.cs +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswer.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; namespace Azure.AI.Language.QuestionAnswering @@ -12,6 +13,38 @@ namespace Azure.AI.Language.QuestionAnswering /// Represents knowledge base answer. public partial class KnowledgeBaseAnswer { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . internal KnowledgeBaseAnswer() { @@ -25,10 +58,14 @@ internal KnowledgeBaseAnswer() /// Answer confidence score, value ranges from 0 to 1. /// ID of the QnA result. /// Source of QnA result. - /// Metadata associated with the answer, useful to categorize or filter question answers. + /// + /// Metadata associated with the answer, useful to categorize or filter question + /// answers. + /// /// Dialog associated with Answer. /// Answer span object of QnA with respect to user's question. - internal KnowledgeBaseAnswer(IReadOnlyList questions, string answer, double? confidence, int? qnaId, string source, IReadOnlyDictionary metadata, KnowledgeBaseAnswerDialog dialog, AnswerSpan shortAnswer) + /// Keeps track of any properties unknown to the library. + internal KnowledgeBaseAnswer(IReadOnlyList questions, string answer, double? confidence, int? qnaId, string source, IReadOnlyDictionary metadata, KnowledgeBaseAnswerDialog dialog, AnswerSpan shortAnswer, IDictionary serializedAdditionalRawData) { Questions = questions; Answer = answer; @@ -38,6 +75,7 @@ internal KnowledgeBaseAnswer(IReadOnlyList questions, string answer, dou Metadata = metadata; Dialog = dialog; ShortAnswer = shortAnswer; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// List of questions associated with the answer. @@ -50,7 +88,10 @@ internal KnowledgeBaseAnswer(IReadOnlyList questions, string answer, dou public int? QnaId { get; } /// Source of QnA result. public string Source { get; } - /// Metadata associated with the answer, useful to categorize or filter question answers. + /// + /// Metadata associated with the answer, useful to categorize or filter question + /// answers. + /// public IReadOnlyDictionary Metadata { get; } /// Dialog associated with Answer. public KnowledgeBaseAnswerDialog Dialog { get; } diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswerContext.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswerContext.Serialization.cs new file mode 100644 index 000000000000..e5fa9c7b31af --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswerContext.Serialization.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering +{ + public partial class KnowledgeBaseAnswerContext : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KnowledgeBaseAnswerContext)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("previousQnaId"u8); + writer.WriteNumberValue(PreviousQnaId); + if (Optional.IsDefined(PreviousQuestion)) + { + writer.WritePropertyName("previousUserQuery"u8); + writer.WriteStringValue(PreviousQuestion); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + KnowledgeBaseAnswerContext IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KnowledgeBaseAnswerContext)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeBaseAnswerContext(document.RootElement, options); + } + + internal static KnowledgeBaseAnswerContext DeserializeKnowledgeBaseAnswerContext(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int previousQnaId = default; + string previousUserQuery = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("previousQnaId"u8)) + { + previousQnaId = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("previousUserQuery"u8)) + { + previousUserQuery = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeBaseAnswerContext(previousQnaId, previousUserQuery, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(KnowledgeBaseAnswerContext)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeBaseAnswerContext IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeKnowledgeBaseAnswerContext(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeBaseAnswerContext)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static KnowledgeBaseAnswerContext FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeKnowledgeBaseAnswerContext(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswerContext.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswerContext.cs new file mode 100644 index 000000000000..5cb3750aedb7 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswerContext.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering +{ + /// Context object with previous QnA's information. + public partial class KnowledgeBaseAnswerContext + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Previous turn top answer result QnA ID. + public KnowledgeBaseAnswerContext(int previousQnaId) + { + PreviousQnaId = previousQnaId; + } + + /// Initializes a new instance of . + /// Previous turn top answer result QnA ID. + /// Previous user query. + /// Keeps track of any properties unknown to the library. + internal KnowledgeBaseAnswerContext(int previousQnaId, string previousQuestion, IDictionary serializedAdditionalRawData) + { + PreviousQnaId = previousQnaId; + PreviousQuestion = previousQuestion; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal KnowledgeBaseAnswerContext() + { + } + + /// Previous turn top answer result QnA ID. + public int PreviousQnaId { get; } + /// Previous user query. + public string PreviousQuestion { get; set; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswerDialog.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswerDialog.Serialization.cs new file mode 100644 index 000000000000..95a347db9b81 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswerDialog.Serialization.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering +{ + public partial class KnowledgeBaseAnswerDialog : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KnowledgeBaseAnswerDialog)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(IsContextOnly)) + { + writer.WritePropertyName("isContextOnly"u8); + writer.WriteBooleanValue(IsContextOnly.Value); + } + if (Optional.IsCollectionDefined(Prompts)) + { + writer.WritePropertyName("prompts"u8); + writer.WriteStartArray(); + foreach (var item in Prompts) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + KnowledgeBaseAnswerDialog IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KnowledgeBaseAnswerDialog)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeBaseAnswerDialog(document.RootElement, options); + } + + internal static KnowledgeBaseAnswerDialog DeserializeKnowledgeBaseAnswerDialog(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? isContextOnly = default; + IReadOnlyList prompts = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("isContextOnly"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isContextOnly = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("prompts"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(KnowledgeBaseAnswerPrompt.DeserializeKnowledgeBaseAnswerPrompt(item, options)); + } + prompts = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeBaseAnswerDialog(isContextOnly, prompts ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(KnowledgeBaseAnswerDialog)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeBaseAnswerDialog IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeKnowledgeBaseAnswerDialog(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeBaseAnswerDialog)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static KnowledgeBaseAnswerDialog FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeKnowledgeBaseAnswerDialog(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswerDialog.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswerDialog.cs new file mode 100644 index 000000000000..034daf21bf9b --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswerDialog.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering +{ + /// Dialog associated with Answer. + public partial class KnowledgeBaseAnswerDialog + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal KnowledgeBaseAnswerDialog() + { + Prompts = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// To mark if a prompt is relevant only with a previous question or not. If true, + /// do not include this QnA as search result for queries without context; + /// otherwise, if false, ignores context and includes this QnA in search result. + /// + /// List of prompts associated with the answer. + /// Keeps track of any properties unknown to the library. + internal KnowledgeBaseAnswerDialog(bool? isContextOnly, IReadOnlyList prompts, IDictionary serializedAdditionalRawData) + { + IsContextOnly = isContextOnly; + Prompts = prompts; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// To mark if a prompt is relevant only with a previous question or not. If true, + /// do not include this QnA as search result for queries without context; + /// otherwise, if false, ignores context and includes this QnA in search result. + /// + public bool? IsContextOnly { get; } + /// List of prompts associated with the answer. + public IReadOnlyList Prompts { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswerPrompt.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswerPrompt.Serialization.cs new file mode 100644 index 000000000000..c7c11e42ca7a --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswerPrompt.Serialization.cs @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering +{ + public partial class KnowledgeBaseAnswerPrompt : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KnowledgeBaseAnswerPrompt)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(DisplayOrder)) + { + writer.WritePropertyName("displayOrder"u8); + writer.WriteNumberValue(DisplayOrder.Value); + } + if (Optional.IsDefined(QnaId)) + { + writer.WritePropertyName("qnaId"u8); + writer.WriteNumberValue(QnaId.Value); + } + if (Optional.IsDefined(DisplayText)) + { + writer.WritePropertyName("displayText"u8); + writer.WriteStringValue(DisplayText); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + KnowledgeBaseAnswerPrompt IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KnowledgeBaseAnswerPrompt)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKnowledgeBaseAnswerPrompt(document.RootElement, options); + } + + internal static KnowledgeBaseAnswerPrompt DeserializeKnowledgeBaseAnswerPrompt(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? displayOrder = default; + int? qnaId = default; + string displayText = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("displayOrder"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + displayOrder = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("qnaId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + qnaId = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("displayText"u8)) + { + displayText = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KnowledgeBaseAnswerPrompt(displayOrder, qnaId, displayText, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(KnowledgeBaseAnswerPrompt)} does not support writing '{options.Format}' format."); + } + } + + KnowledgeBaseAnswerPrompt IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeKnowledgeBaseAnswerPrompt(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KnowledgeBaseAnswerPrompt)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static KnowledgeBaseAnswerPrompt FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeKnowledgeBaseAnswerPrompt(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswerPrompt.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswerPrompt.cs new file mode 100644 index 000000000000..18e6cb3dc123 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/KnowledgeBaseAnswerPrompt.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering +{ + /// Prompt for an answer. + public partial class KnowledgeBaseAnswerPrompt + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal KnowledgeBaseAnswerPrompt() + { + } + + /// Initializes a new instance of . + /// Index of the prompt - used in ordering of the prompts. + /// QnA ID corresponding to the prompt. + /// Text displayed to represent a follow up question prompt. + /// Keeps track of any properties unknown to the library. + internal KnowledgeBaseAnswerPrompt(int? displayOrder, int? qnaId, string displayText, IDictionary serializedAdditionalRawData) + { + DisplayOrder = displayOrder; + QnaId = qnaId; + DisplayText = displayText; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Index of the prompt - used in ordering of the prompts. + public int? DisplayOrder { get; } + /// QnA ID corresponding to the prompt. + public int? QnaId { get; } + /// Text displayed to represent a follow up question prompt. + public string DisplayText { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/LogicalOperationKind.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/LogicalOperationKind.cs similarity index 100% rename from sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/LogicalOperationKind.cs rename to sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/LogicalOperationKind.cs diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/MetadataFilter.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/MetadataFilter.Serialization.cs new file mode 100644 index 000000000000..7e5300db315b --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/MetadataFilter.Serialization.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering +{ + public partial class MetadataFilter : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetadataFilter)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartArray(); + foreach (var item in Metadata) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(LogicalOperation)) + { + writer.WritePropertyName("logicalOperation"u8); + writer.WriteStringValue(LogicalOperation.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MetadataFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetadataFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetadataFilter(document.RootElement, options); + } + + internal static MetadataFilter DeserializeMetadataFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList metadata = default; + LogicalOperationKind? logicalOperation = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetadataRecord.DeserializeMetadataRecord(item, options)); + } + metadata = array; + continue; + } + if (property.NameEquals("logicalOperation"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + logicalOperation = new LogicalOperationKind(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MetadataFilter(metadata ?? new ChangeTrackingList(), logicalOperation, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MetadataFilter)} does not support writing '{options.Format}' format."); + } + } + + MetadataFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMetadataFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetadataFilter)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MetadataFilter FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMetadataFilter(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/MetadataFilter.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/MetadataFilter.cs new file mode 100644 index 000000000000..a599ab669791 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/MetadataFilter.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering +{ + /// Find QnAs that are associated with the given list of metadata. + public partial class MetadataFilter + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public MetadataFilter() + { + Metadata = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Dictionary of string. + /// Operation used to join metadata filters. + /// Keeps track of any properties unknown to the library. + internal MetadataFilter(IList metadata, LogicalOperationKind? logicalOperation, IDictionary serializedAdditionalRawData) + { + Metadata = metadata; + LogicalOperation = logicalOperation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Dictionary of string. + public IList Metadata { get; } + /// Operation used to join metadata filters. + public LogicalOperationKind? LogicalOperation { get; set; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/MetadataRecord.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/MetadataRecord.Serialization.cs new file mode 100644 index 000000000000..3ae40a335f3b --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/MetadataRecord.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering +{ + public partial class MetadataRecord : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetadataRecord)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("key"u8); + writer.WriteStringValue(Key); + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MetadataRecord IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetadataRecord)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetadataRecord(document.RootElement, options); + } + + internal static MetadataRecord DeserializeMetadataRecord(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string key = default; + string value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("key"u8)) + { + key = property.Value.GetString(); + continue; + } + if (property.NameEquals("value"u8)) + { + value = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MetadataRecord(key, value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MetadataRecord)} does not support writing '{options.Format}' format."); + } + } + + MetadataRecord IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMetadataRecord(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetadataRecord)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MetadataRecord FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMetadataRecord(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/MetadataRecord.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/MetadataRecord.cs new file mode 100644 index 000000000000..d99209fc3e67 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/MetadataRecord.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering +{ + /// Object to provide the key value pair for each metadata. + public partial class MetadataRecord + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Metadata Key from Metadata dictionary used in the QnA. + /// Metadata Value from Metadata dictionary used in the QnA. + /// or is null. + public MetadataRecord(string key, string value) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + Key = key; + Value = value; + } + + /// Initializes a new instance of . + /// Metadata Key from Metadata dictionary used in the QnA. + /// Metadata Value from Metadata dictionary used in the QnA. + /// Keeps track of any properties unknown to the library. + internal MetadataRecord(string key, string value, IDictionary serializedAdditionalRawData) + { + Key = key; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MetadataRecord() + { + } + + /// Metadata Key from Metadata dictionary used in the QnA. + public string Key { get; } + /// Metadata Value from Metadata dictionary used in the QnA. + public string Value { get; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswerSpan.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswerSpan.Serialization.cs deleted file mode 100644 index 6adcb998e4d5..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswerSpan.Serialization.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Text.Json; - -namespace Azure.AI.Language.QuestionAnswering -{ - public partial class AnswerSpan - { - internal static AnswerSpan DeserializeAnswerSpan(JsonElement element) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string text = default; - double? confidenceScore = default; - int? offset = default; - int? length = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("text"u8)) - { - text = property.Value.GetString(); - continue; - } - if (property.NameEquals("confidenceScore"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - confidenceScore = property.Value.GetDouble(); - continue; - } - if (property.NameEquals("offset"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - offset = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("length"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - length = property.Value.GetInt32(); - continue; - } - } - return new AnswerSpan(text, confidenceScore, offset, length); - } - - /// Deserializes the model from a raw response. - /// The response to deserialize the model from. - internal static AnswerSpan FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAnswerSpan(document.RootElement); - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswerSpan.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswerSpan.cs deleted file mode 100644 index b1e713086df7..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswerSpan.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -namespace Azure.AI.Language.QuestionAnswering -{ - /// Answer span object of QnA. - public partial class AnswerSpan - { - /// Initializes a new instance of . - internal AnswerSpan() - { - } - - /// Initializes a new instance of . - /// Predicted text of answer span. - /// Predicted score of answer span, value ranges from 0 to 1. - /// The answer span offset from the start of answer. - /// The length of the answer span. - internal AnswerSpan(string text, double? confidence, int? offset, int? length) - { - Text = text; - Confidence = confidence; - Offset = offset; - Length = length; - } - - /// Predicted text of answer span. - public string Text { get; } - /// Predicted score of answer span, value ranges from 0 to 1. - public double? Confidence { get; } - /// The answer span offset from the start of answer. - public int? Offset { get; } - /// The length of the answer span. - public int? Length { get; } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersFromTextOptions.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersFromTextOptions.Serialization.cs deleted file mode 100644 index 6528a320556c..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersFromTextOptions.Serialization.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Language.QuestionAnswering -{ - public partial class AnswersFromTextOptions : IUtf8JsonSerializable - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - writer.WritePropertyName("question"u8); - writer.WriteStringValue(Question); - writer.WritePropertyName("records"u8); - writer.WriteStartArray(); - foreach (var item in TextDocuments) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - if (Optional.IsDefined(Language)) - { - writer.WritePropertyName("language"u8); - writer.WriteStringValue(Language); - } - if (Optional.IsDefined(StringIndexType)) - { - writer.WritePropertyName("stringIndexType"u8); - writer.WriteStringValue(StringIndexType.Value.ToString()); - } - writer.WriteEndObject(); - } - - /// Convert into a . - internal virtual RequestContent ToRequestContent() - { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); - return content; - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersFromTextOptions.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersFromTextOptions.cs deleted file mode 100644 index 4278fabd0374..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersFromTextOptions.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Azure.AI.Language.QuestionAnswering -{ - /// The question and text record parameters to answer. - public partial class AnswersFromTextOptions - { - /// Initializes a new instance of . - /// User question to query against the given text records. - /// Text records to be searched for given question. - /// or is null. - public AnswersFromTextOptions(string question, IEnumerable textDocuments) - { - Argument.AssertNotNull(question, nameof(question)); - Argument.AssertNotNull(textDocuments, nameof(textDocuments)); - - Question = question; - TextDocuments = textDocuments.ToList(); - } - - /// Initializes a new instance of . - /// User question to query against the given text records. - /// Text records to be searched for given question. - /// Language of the text records. This is BCP-47 representation of a language. For example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as default. - /// Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. - internal AnswersFromTextOptions(string question, IList textDocuments, string language, StringIndexType? stringIndexType) - { - Question = question; - TextDocuments = textDocuments; - Language = language; - StringIndexType = stringIndexType; - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersFromTextResult.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersFromTextResult.Serialization.cs deleted file mode 100644 index 8a3fd4d4de07..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersFromTextResult.Serialization.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Collections.Generic; -using System.Text.Json; - -namespace Azure.AI.Language.QuestionAnswering -{ - public partial class AnswersFromTextResult - { - internal static AnswersFromTextResult DeserializeAnswersFromTextResult(JsonElement element) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList answers = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("answers"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(TextAnswer.DeserializeTextAnswer(item)); - } - answers = array; - continue; - } - } - return new AnswersFromTextResult(answers ?? new ChangeTrackingList()); - } - - /// Deserializes the model from a raw response. - /// The response to deserialize the model from. - internal static AnswersFromTextResult FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAnswersFromTextResult(document.RootElement); - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersFromTextResult.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersFromTextResult.cs deleted file mode 100644 index d07568c24fb6..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersFromTextResult.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Collections.Generic; - -namespace Azure.AI.Language.QuestionAnswering -{ - /// Represents the answer results. - public partial class AnswersFromTextResult - { - /// Initializes a new instance of . - internal AnswersFromTextResult() - { - Answers = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// Represents the answer results. - internal AnswersFromTextResult(IReadOnlyList answers) - { - Answers = answers; - } - - /// Represents the answer results. - public IReadOnlyList Answers { get; } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersOptions.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersOptions.Serialization.cs deleted file mode 100644 index 3a071beafbeb..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersOptions.Serialization.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Language.QuestionAnswering -{ - public partial class AnswersOptions : IUtf8JsonSerializable - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - if (Optional.IsDefined(QnaId)) - { - writer.WritePropertyName("qnaId"u8); - writer.WriteNumberValue(QnaId.Value); - } - if (Optional.IsDefined(Question)) - { - writer.WritePropertyName("question"u8); - writer.WriteStringValue(Question); - } - if (Optional.IsDefined(Size)) - { - writer.WritePropertyName("top"u8); - writer.WriteNumberValue(Size.Value); - } - if (Optional.IsDefined(UserId)) - { - writer.WritePropertyName("userId"u8); - writer.WriteStringValue(UserId); - } - if (Optional.IsDefined(ConfidenceThreshold)) - { - writer.WritePropertyName("confidenceScoreThreshold"u8); - writer.WriteNumberValue(ConfidenceThreshold.Value); - } - if (Optional.IsDefined(AnswerContext)) - { - writer.WritePropertyName("context"u8); - writer.WriteObjectValue(AnswerContext); - } - if (Optional.IsDefined(RankerKind)) - { - writer.WritePropertyName("rankerType"u8); - writer.WriteStringValue(RankerKind.Value.ToString()); - } - if (Optional.IsDefined(Filters)) - { - writer.WritePropertyName("filters"u8); - writer.WriteObjectValue(Filters); - } - if (Optional.IsDefined(ShortAnswerOptions)) - { - writer.WritePropertyName("answerSpanRequest"u8); - writer.WriteObjectValue(ShortAnswerOptions); - } - if (Optional.IsDefined(IncludeUnstructuredSources)) - { - writer.WritePropertyName("includeUnstructuredSources"u8); - writer.WriteBooleanValue(IncludeUnstructuredSources.Value); - } - writer.WriteEndObject(); - } - - /// Convert into a . - internal virtual RequestContent ToRequestContent() - { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); - return content; - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersResult.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersResult.Serialization.cs deleted file mode 100644 index 9f5d8809830d..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersResult.Serialization.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Collections.Generic; -using System.Text.Json; - -namespace Azure.AI.Language.QuestionAnswering -{ - public partial class AnswersResult - { - internal static AnswersResult DeserializeAnswersResult(JsonElement element) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList answers = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("answers"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(KnowledgeBaseAnswer.DeserializeKnowledgeBaseAnswer(item)); - } - answers = array; - continue; - } - } - return new AnswersResult(answers ?? new ChangeTrackingList()); - } - - /// Deserializes the model from a raw response. - /// The response to deserialize the model from. - internal static AnswersResult FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAnswersResult(document.RootElement); - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersResult.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersResult.cs deleted file mode 100644 index 4cc86b61848b..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/AnswersResult.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Collections.Generic; - -namespace Azure.AI.Language.QuestionAnswering -{ - /// Represents List of Question Answers. - public partial class AnswersResult - { - /// Initializes a new instance of . - internal AnswersResult() - { - Answers = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// Represents Answer Result list. - internal AnswersResult(IReadOnlyList answers) - { - Answers = answers; - } - - /// Represents Answer Result list. - public IReadOnlyList Answers { get; } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/Error.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/Error.Serialization.cs deleted file mode 100644 index 4a2a327b887c..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/Error.Serialization.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Collections.Generic; -using System.Text.Json; - -namespace Azure.AI.Language.QuestionAnswering -{ - internal partial class Error - { - internal static Error DeserializeError(JsonElement element) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - ErrorCode code = default; - string message = default; - string target = default; - IReadOnlyList details = default; - InnerErrorModel innererror = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("code"u8)) - { - code = new ErrorCode(property.Value.GetString()); - continue; - } - if (property.NameEquals("message"u8)) - { - message = property.Value.GetString(); - continue; - } - if (property.NameEquals("target"u8)) - { - target = property.Value.GetString(); - continue; - } - if (property.NameEquals("details"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(DeserializeError(item)); - } - details = array; - continue; - } - if (property.NameEquals("innererror"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - innererror = InnerErrorModel.DeserializeInnerErrorModel(property.Value); - continue; - } - } - return new Error(code, message, target, details ?? new ChangeTrackingList(), innererror); - } - - /// Deserializes the model from a raw response. - /// The response to deserialize the model from. - internal static Error FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeError(document.RootElement); - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/Error.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/Error.cs deleted file mode 100644 index 5442b1db9411..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/Error.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Language.QuestionAnswering -{ - /// The error object. - internal partial class Error - { - /// Initializes a new instance of . - /// One of a server-defined set of error codes. - /// A human-readable representation of the error. - /// is null. - internal Error(ErrorCode code, string message) - { - Argument.AssertNotNull(message, nameof(message)); - - Code = code; - Message = message; - Details = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// One of a server-defined set of error codes. - /// A human-readable representation of the error. - /// The target of the error. - /// An array of details about specific errors that led to this reported error. - /// An object containing more specific information than the current object about the error. - internal Error(ErrorCode code, string message, string target, IReadOnlyList details, InnerErrorModel innererror) - { - Code = code; - Message = message; - Target = target; - Details = details; - Innererror = innererror; - } - - /// One of a server-defined set of error codes. - public ErrorCode Code { get; } - /// A human-readable representation of the error. - public string Message { get; } - /// The target of the error. - public string Target { get; } - /// An array of details about specific errors that led to this reported error. - public IReadOnlyList Details { get; } - /// An object containing more specific information than the current object about the error. - public InnerErrorModel Innererror { get; } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/ErrorResponse.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/ErrorResponse.Serialization.cs deleted file mode 100644 index 496a60e55ce2..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/ErrorResponse.Serialization.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Text.Json; - -namespace Azure.AI.Language.QuestionAnswering -{ - internal partial class ErrorResponse - { - internal static ErrorResponse DeserializeErrorResponse(JsonElement element) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - Error error = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("error"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - error = Error.DeserializeError(property.Value); - continue; - } - } - return new ErrorResponse(error); - } - - /// Deserializes the model from a raw response. - /// The response to deserialize the model from. - internal static ErrorResponse FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeErrorResponse(document.RootElement); - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/ErrorResponse.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/ErrorResponse.cs deleted file mode 100644 index 389079602e0f..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/ErrorResponse.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -namespace Azure.AI.Language.QuestionAnswering -{ - /// Error response. - internal partial class ErrorResponse - { - /// Initializes a new instance of . - internal ErrorResponse() - { - } - - /// Initializes a new instance of . - /// The error object. - internal ErrorResponse(Error error) - { - Error = error; - } - - /// The error object. - public Error Error { get; } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/InnerErrorModel.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/InnerErrorModel.Serialization.cs deleted file mode 100644 index 9ecbbb5b5690..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/InnerErrorModel.Serialization.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Collections.Generic; -using System.Text.Json; - -namespace Azure.AI.Language.QuestionAnswering -{ - internal partial class InnerErrorModel - { - internal static InnerErrorModel DeserializeInnerErrorModel(JsonElement element) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InnerErrorCode code = default; - string message = default; - IReadOnlyDictionary details = default; - string target = default; - InnerErrorModel innererror = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("code"u8)) - { - code = new InnerErrorCode(property.Value.GetString()); - continue; - } - if (property.NameEquals("message"u8)) - { - message = property.Value.GetString(); - continue; - } - if (property.NameEquals("details"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - details = dictionary; - continue; - } - if (property.NameEquals("target"u8)) - { - target = property.Value.GetString(); - continue; - } - if (property.NameEquals("innererror"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - innererror = DeserializeInnerErrorModel(property.Value); - continue; - } - } - return new InnerErrorModel(code, message, details ?? new ChangeTrackingDictionary(), target, innererror); - } - - /// Deserializes the model from a raw response. - /// The response to deserialize the model from. - internal static InnerErrorModel FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeInnerErrorModel(document.RootElement); - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/InnerErrorModel.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/InnerErrorModel.cs deleted file mode 100644 index c869c06e53cf..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/InnerErrorModel.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.Language.QuestionAnswering -{ - /// An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. - internal partial class InnerErrorModel - { - /// Initializes a new instance of . - /// One of a server-defined set of error codes. - /// Error message. - /// is null. - internal InnerErrorModel(InnerErrorCode code, string message) - { - Argument.AssertNotNull(message, nameof(message)); - - Code = code; - Message = message; - Details = new ChangeTrackingDictionary(); - } - - /// Initializes a new instance of . - /// One of a server-defined set of error codes. - /// Error message. - /// Error details. - /// Error target. - /// An object containing more specific information than the current object about the error. - internal InnerErrorModel(InnerErrorCode code, string message, IReadOnlyDictionary details, string target, InnerErrorModel innererror) - { - Code = code; - Message = message; - Details = details; - Target = target; - Innererror = innererror; - } - - /// One of a server-defined set of error codes. - public InnerErrorCode Code { get; } - /// Error message. - public string Message { get; } - /// Error details. - public IReadOnlyDictionary Details { get; } - /// Error target. - public string Target { get; } - /// An object containing more specific information than the current object about the error. - public InnerErrorModel Innererror { get; } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswer.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswer.Serialization.cs deleted file mode 100644 index 41eab047d79c..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswer.Serialization.cs +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Collections.Generic; -using System.Text.Json; - -namespace Azure.AI.Language.QuestionAnswering -{ - public partial class KnowledgeBaseAnswer - { - internal static KnowledgeBaseAnswer DeserializeKnowledgeBaseAnswer(JsonElement element) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList questions = default; - string answer = default; - double? confidenceScore = default; - int? id = default; - string source = default; - IReadOnlyDictionary metadata = default; - KnowledgeBaseAnswerDialog dialog = default; - AnswerSpan answerSpan = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("questions"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - questions = array; - continue; - } - if (property.NameEquals("answer"u8)) - { - answer = property.Value.GetString(); - continue; - } - if (property.NameEquals("confidenceScore"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - confidenceScore = property.Value.GetDouble(); - continue; - } - if (property.NameEquals("id"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - id = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("source"u8)) - { - source = property.Value.GetString(); - continue; - } - if (property.NameEquals("metadata"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; - } - if (property.NameEquals("dialog"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - dialog = KnowledgeBaseAnswerDialog.DeserializeKnowledgeBaseAnswerDialog(property.Value); - continue; - } - if (property.NameEquals("answerSpan"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - answerSpan = AnswerSpan.DeserializeAnswerSpan(property.Value); - continue; - } - } - return new KnowledgeBaseAnswer( - questions ?? new ChangeTrackingList(), - answer, - confidenceScore, - id, - source, - metadata ?? new ChangeTrackingDictionary(), - dialog, - answerSpan); - } - - /// Deserializes the model from a raw response. - /// The response to deserialize the model from. - internal static KnowledgeBaseAnswer FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeKnowledgeBaseAnswer(document.RootElement); - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswerContext.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswerContext.Serialization.cs deleted file mode 100644 index be3105101fe0..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswerContext.Serialization.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Language.QuestionAnswering -{ - public partial class KnowledgeBaseAnswerContext : IUtf8JsonSerializable - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - writer.WritePropertyName("previousQnaId"u8); - writer.WriteNumberValue(PreviousQnaId); - if (Optional.IsDefined(PreviousQuestion)) - { - writer.WritePropertyName("previousUserQuery"u8); - writer.WriteStringValue(PreviousQuestion); - } - writer.WriteEndObject(); - } - - /// Convert into a . - internal virtual RequestContent ToRequestContent() - { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); - return content; - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswerContext.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswerContext.cs deleted file mode 100644 index db7a47ec848c..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswerContext.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -namespace Azure.AI.Language.QuestionAnswering -{ - /// Context object with previous QnA's information. - public partial class KnowledgeBaseAnswerContext - { - /// Initializes a new instance of . - /// Previous turn top answer result QnA ID. - public KnowledgeBaseAnswerContext(int previousQnaId) - { - PreviousQnaId = previousQnaId; - } - - /// Initializes a new instance of . - /// Previous turn top answer result QnA ID. - /// Previous user query. - internal KnowledgeBaseAnswerContext(int previousQnaId, string previousQuestion) - { - PreviousQnaId = previousQnaId; - PreviousQuestion = previousQuestion; - } - - /// Previous turn top answer result QnA ID. - public int PreviousQnaId { get; } - /// Previous user query. - public string PreviousQuestion { get; set; } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswerDialog.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswerDialog.Serialization.cs deleted file mode 100644 index 9e829ef1772e..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswerDialog.Serialization.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Collections.Generic; -using System.Text.Json; - -namespace Azure.AI.Language.QuestionAnswering -{ - public partial class KnowledgeBaseAnswerDialog - { - internal static KnowledgeBaseAnswerDialog DeserializeKnowledgeBaseAnswerDialog(JsonElement element) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - bool? isContextOnly = default; - IReadOnlyList prompts = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("isContextOnly"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - isContextOnly = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("prompts"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(KnowledgeBaseAnswerPrompt.DeserializeKnowledgeBaseAnswerPrompt(item)); - } - prompts = array; - continue; - } - } - return new KnowledgeBaseAnswerDialog(isContextOnly, prompts ?? new ChangeTrackingList()); - } - - /// Deserializes the model from a raw response. - /// The response to deserialize the model from. - internal static KnowledgeBaseAnswerDialog FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeKnowledgeBaseAnswerDialog(document.RootElement); - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswerDialog.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswerDialog.cs deleted file mode 100644 index 218b1b64529f..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswerDialog.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Collections.Generic; - -namespace Azure.AI.Language.QuestionAnswering -{ - /// Dialog associated with Answer. - public partial class KnowledgeBaseAnswerDialog - { - /// Initializes a new instance of . - internal KnowledgeBaseAnswerDialog() - { - Prompts = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// To mark if a prompt is relevant only with a previous question or not. If true, do not include this QnA as search result for queries without context; otherwise, if false, ignores context and includes this QnA in search result. - /// List of prompts associated with the answer. - internal KnowledgeBaseAnswerDialog(bool? isContextOnly, IReadOnlyList prompts) - { - IsContextOnly = isContextOnly; - Prompts = prompts; - } - - /// To mark if a prompt is relevant only with a previous question or not. If true, do not include this QnA as search result for queries without context; otherwise, if false, ignores context and includes this QnA in search result. - public bool? IsContextOnly { get; } - /// List of prompts associated with the answer. - public IReadOnlyList Prompts { get; } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswerPrompt.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswerPrompt.Serialization.cs deleted file mode 100644 index c6adf1e285e1..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswerPrompt.Serialization.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Text.Json; - -namespace Azure.AI.Language.QuestionAnswering -{ - public partial class KnowledgeBaseAnswerPrompt - { - internal static KnowledgeBaseAnswerPrompt DeserializeKnowledgeBaseAnswerPrompt(JsonElement element) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - int? displayOrder = default; - int? qnaId = default; - string displayText = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("displayOrder"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - displayOrder = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("qnaId"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - qnaId = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("displayText"u8)) - { - displayText = property.Value.GetString(); - continue; - } - } - return new KnowledgeBaseAnswerPrompt(displayOrder, qnaId, displayText); - } - - /// Deserializes the model from a raw response. - /// The response to deserialize the model from. - internal static KnowledgeBaseAnswerPrompt FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeKnowledgeBaseAnswerPrompt(document.RootElement); - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswerPrompt.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswerPrompt.cs deleted file mode 100644 index b7fc5793bda3..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/KnowledgeBaseAnswerPrompt.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -namespace Azure.AI.Language.QuestionAnswering -{ - /// Prompt for an answer. - public partial class KnowledgeBaseAnswerPrompt - { - /// Initializes a new instance of . - internal KnowledgeBaseAnswerPrompt() - { - } - - /// Initializes a new instance of . - /// Index of the prompt - used in ordering of the prompts. - /// QnA ID corresponding to the prompt. - /// Text displayed to represent a follow up question prompt. - internal KnowledgeBaseAnswerPrompt(int? displayOrder, int? qnaId, string displayText) - { - DisplayOrder = displayOrder; - QnaId = qnaId; - DisplayText = displayText; - } - - /// Index of the prompt - used in ordering of the prompts. - public int? DisplayOrder { get; } - /// QnA ID corresponding to the prompt. - public int? QnaId { get; } - /// Text displayed to represent a follow up question prompt. - public string DisplayText { get; } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/MetadataFilter.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/MetadataFilter.Serialization.cs deleted file mode 100644 index ecf39d94923e..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/MetadataFilter.Serialization.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Language.QuestionAnswering -{ - public partial class MetadataFilter : IUtf8JsonSerializable - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - if (Optional.IsCollectionDefined(Metadata)) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartArray(); - foreach (var item in Metadata) - { - writer.WriteObjectValue(item); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(LogicalOperation)) - { - writer.WritePropertyName("logicalOperation"u8); - writer.WriteStringValue(LogicalOperation.Value.ToString()); - } - writer.WriteEndObject(); - } - - /// Convert into a . - internal virtual RequestContent ToRequestContent() - { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); - return content; - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/MetadataFilter.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/MetadataFilter.cs deleted file mode 100644 index 6478572d2b44..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/MetadataFilter.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Collections.Generic; - -namespace Azure.AI.Language.QuestionAnswering -{ - /// Find QnAs that are associated with the given list of metadata. - public partial class MetadataFilter - { - /// Initializes a new instance of . - public MetadataFilter() - { - Metadata = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// - /// Operation used to join metadata filters. - internal MetadataFilter(IList metadata, LogicalOperationKind? logicalOperation) - { - Metadata = metadata; - LogicalOperation = logicalOperation; - } - - /// Gets the metadata. - public IList Metadata { get; } - /// Operation used to join metadata filters. - public LogicalOperationKind? LogicalOperation { get; set; } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/MetadataRecord.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/MetadataRecord.Serialization.cs deleted file mode 100644 index b6781558b94f..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/MetadataRecord.Serialization.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Language.QuestionAnswering -{ - public partial class MetadataRecord : IUtf8JsonSerializable - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - writer.WritePropertyName("key"u8); - writer.WriteStringValue(Key); - writer.WritePropertyName("value"u8); - writer.WriteStringValue(Value); - writer.WriteEndObject(); - } - - /// Convert into a . - internal virtual RequestContent ToRequestContent() - { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); - return content; - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/MetadataRecord.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/MetadataRecord.cs deleted file mode 100644 index 71cc4a729254..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/MetadataRecord.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; - -namespace Azure.AI.Language.QuestionAnswering -{ - /// Object to provide the key value pair for each metadata. - public partial class MetadataRecord - { - /// Initializes a new instance of . - /// Metadata Key from Metadata dictionary used in the QnA. - /// Metadata Value from Metadata dictionary used in the QnA. - /// or is null. - public MetadataRecord(string key, string value) - { - Argument.AssertNotNull(key, nameof(key)); - Argument.AssertNotNull(value, nameof(value)); - - Key = key; - Value = value; - } - - /// Metadata Key from Metadata dictionary used in the QnA. - public string Key { get; } - /// Metadata Value from Metadata dictionary used in the QnA. - public string Value { get; } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/QueryFilters.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/QueryFilters.Serialization.cs deleted file mode 100644 index 839d23dba7e0..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/QueryFilters.Serialization.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Language.QuestionAnswering -{ - public partial class QueryFilters : IUtf8JsonSerializable - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - if (Optional.IsDefined(MetadataFilter)) - { - writer.WritePropertyName("metadataFilter"u8); - writer.WriteObjectValue(MetadataFilter); - } - if (Optional.IsCollectionDefined(SourceFilter)) - { - writer.WritePropertyName("sourceFilter"u8); - writer.WriteStartArray(); - foreach (var item in SourceFilter) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(LogicalOperation)) - { - writer.WritePropertyName("logicalOperation"u8); - writer.WriteStringValue(LogicalOperation.Value.ToString()); - } - writer.WriteEndObject(); - } - - /// Convert into a . - internal virtual RequestContent ToRequestContent() - { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); - return content; - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/QueryFilters.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/QueryFilters.cs deleted file mode 100644 index 5918d76e2244..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/QueryFilters.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Collections.Generic; - -namespace Azure.AI.Language.QuestionAnswering -{ - /// filters over knowledge base. - public partial class QueryFilters - { - /// Initializes a new instance of . - public QueryFilters() - { - SourceFilter = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// Find QnAs that are associated with the given list of metadata. - /// Find QnAs that are associated with any of the given list of sources in knowledge base. - /// Logical operation used to join metadata filter with source filter. - internal QueryFilters(MetadataFilter metadataFilter, IList sourceFilter, LogicalOperationKind? logicalOperation) - { - MetadataFilter = metadataFilter; - SourceFilter = sourceFilter; - LogicalOperation = logicalOperation; - } - - /// Find QnAs that are associated with the given list of metadata. - public MetadataFilter MetadataFilter { get; set; } - /// Find QnAs that are associated with any of the given list of sources in knowledge base. - public IList SourceFilter { get; } - /// Logical operation used to join metadata filter with source filter. - public LogicalOperationKind? LogicalOperation { get; set; } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/ShortAnswerOptions.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/ShortAnswerOptions.Serialization.cs deleted file mode 100644 index d1601c87999b..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/ShortAnswerOptions.Serialization.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Language.QuestionAnswering -{ - public partial class ShortAnswerOptions : IUtf8JsonSerializable - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - writer.WritePropertyName("enable"u8); - writer.WriteBooleanValue(Enable); - if (Optional.IsDefined(ConfidenceThreshold)) - { - writer.WritePropertyName("confidenceScoreThreshold"u8); - writer.WriteNumberValue(ConfidenceThreshold.Value); - } - if (Optional.IsDefined(Size)) - { - writer.WritePropertyName("topAnswersWithSpan"u8); - writer.WriteNumberValue(Size.Value); - } - writer.WriteEndObject(); - } - - /// Convert into a . - internal virtual RequestContent ToRequestContent() - { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); - return content; - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/ShortAnswerOptions.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/ShortAnswerOptions.cs deleted file mode 100644 index 83f0e0c280db..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/ShortAnswerOptions.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -namespace Azure.AI.Language.QuestionAnswering -{ - /// To configure Answer span prediction feature. - public partial class ShortAnswerOptions - { - /// Initializes a new instance of . - public ShortAnswerOptions() - { - Enable = true; - } - - /// Initializes a new instance of . - /// Enable or disable Answer Span prediction. - /// Minimum threshold score required to include an answer span, value ranges from 0 to 1. - /// Number of Top answers to be considered for span prediction from 1 to 10. - internal ShortAnswerOptions(bool enable, double? confidenceThreshold, int? size) - { - Enable = enable; - ConfidenceThreshold = confidenceThreshold; - Size = size; - } - /// Minimum threshold score required to include an answer span, value ranges from 0 to 1. - public double? ConfidenceThreshold { get; set; } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/TextAnswer.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/TextAnswer.Serialization.cs deleted file mode 100644 index 3b5f2e42b186..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/TextAnswer.Serialization.cs +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Text.Json; - -namespace Azure.AI.Language.QuestionAnswering -{ - public partial class TextAnswer - { - internal static TextAnswer DeserializeTextAnswer(JsonElement element) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string answer = default; - double? confidenceScore = default; - string id = default; - AnswerSpan answerSpan = default; - int? offset = default; - int? length = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("answer"u8)) - { - answer = property.Value.GetString(); - continue; - } - if (property.NameEquals("confidenceScore"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - confidenceScore = property.Value.GetDouble(); - continue; - } - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("answerSpan"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - answerSpan = AnswerSpan.DeserializeAnswerSpan(property.Value); - continue; - } - if (property.NameEquals("offset"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - offset = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("length"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - length = property.Value.GetInt32(); - continue; - } - } - return new TextAnswer( - answer, - confidenceScore, - id, - answerSpan, - offset, - length); - } - - /// Deserializes the model from a raw response. - /// The response to deserialize the model from. - internal static TextAnswer FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTextAnswer(document.RootElement); - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/TextDocument.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/TextDocument.Serialization.cs deleted file mode 100644 index b68596ee71f6..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/TextDocument.Serialization.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Text.Json; -using Azure.Core; - -namespace Azure.AI.Language.QuestionAnswering -{ - public partial class TextDocument : IUtf8JsonSerializable - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); - writer.WriteEndObject(); - } - - /// Convert into a . - internal virtual RequestContent ToRequestContent() - { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this); - return content; - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/TextDocument.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/TextDocument.cs deleted file mode 100644 index 0154cac3400f..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/TextDocument.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; - -namespace Azure.AI.Language.QuestionAnswering -{ - /// Represent input text record to be queried. - public partial class TextDocument - { - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QueryFilters.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QueryFilters.Serialization.cs new file mode 100644 index 000000000000..4bc3b3f9aa91 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QueryFilters.Serialization.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering +{ + public partial class QueryFilters : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QueryFilters)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(MetadataFilter)) + { + writer.WritePropertyName("metadataFilter"u8); + writer.WriteObjectValue(MetadataFilter, options); + } + if (Optional.IsCollectionDefined(SourceFilter)) + { + writer.WritePropertyName("sourceFilter"u8); + writer.WriteStartArray(); + foreach (var item in SourceFilter) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(LogicalOperation)) + { + writer.WritePropertyName("logicalOperation"u8); + writer.WriteStringValue(LogicalOperation.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + QueryFilters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QueryFilters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQueryFilters(document.RootElement, options); + } + + internal static QueryFilters DeserializeQueryFilters(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MetadataFilter metadataFilter = default; + IList sourceFilter = default; + LogicalOperationKind? logicalOperation = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("metadataFilter"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + metadataFilter = MetadataFilter.DeserializeMetadataFilter(property.Value, options); + continue; + } + if (property.NameEquals("sourceFilter"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + sourceFilter = array; + continue; + } + if (property.NameEquals("logicalOperation"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + logicalOperation = new LogicalOperationKind(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new QueryFilters(metadataFilter, sourceFilter ?? new ChangeTrackingList(), logicalOperation, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(QueryFilters)} does not support writing '{options.Format}' format."); + } + } + + QueryFilters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQueryFilters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QueryFilters)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static QueryFilters FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeQueryFilters(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QueryFilters.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QueryFilters.cs new file mode 100644 index 000000000000..bb434817bb94 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QueryFilters.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering +{ + /// filters over knowledge base. + public partial class QueryFilters + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public QueryFilters() + { + SourceFilter = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Find QnAs that are associated with the given list of metadata. + /// + /// Find QnAs that are associated with any of the given list of sources in + /// knowledge base. + /// + /// Logical operation used to join metadata filter with source filter. + /// Keeps track of any properties unknown to the library. + internal QueryFilters(MetadataFilter metadataFilter, IList sourceFilter, LogicalOperationKind? logicalOperation, IDictionary serializedAdditionalRawData) + { + MetadataFilter = metadataFilter; + SourceFilter = sourceFilter; + LogicalOperation = logicalOperation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Find QnAs that are associated with the given list of metadata. + public MetadataFilter MetadataFilter { get; set; } + /// + /// Find QnAs that are associated with any of the given list of sources in + /// knowledge base. + /// + public IList SourceFilter { get; } + /// Logical operation used to join metadata filter with source filter. + public LogicalOperationKind? LogicalOperation { get; set; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnswering.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnswering.cs new file mode 100644 index 000000000000..f05b72e52ac4 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnswering.cs @@ -0,0 +1,338 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Language.QuestionAnswering +{ + // Data plane generated sub-client. + /// The QuestionAnswering sub-client. + public partial class QuestionAnswering + { + private const string AuthorizationHeader = "Ocp-Apim-Subscription-Key"; + private readonly AzureKeyCredential _keyCredential; + private static readonly string[] AuthorizationScopes = new string[] { "https://cognitiveservices.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of QuestionAnswering for mocking. + protected QuestionAnswering() + { + } + + /// Initializes a new instance of QuestionAnswering. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// The token credential to copy. + /// Supported Cognitive Services endpoint (e.g., https://<resource-name>.api.cognitiveservices.azure.com). + /// The API version to use for this operation. + internal QuestionAnswering(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Answers the specified question using your knowledge base. + /// The name of the project to use. + /// The name of the specific deployment of the project to use. + /// Post body of the request. + /// The cancellation token to use. + /// , or is null. + /// + public virtual async Task> GetAnswersAsync(string projectName, string deploymentName, AnswersOptions knowledgeBaseQueryOptions, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(projectName, nameof(projectName)); + Argument.AssertNotNull(deploymentName, nameof(deploymentName)); + Argument.AssertNotNull(knowledgeBaseQueryOptions, nameof(knowledgeBaseQueryOptions)); + + using RequestContent content = knowledgeBaseQueryOptions.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAnswersAsync(projectName, deploymentName, content, context).ConfigureAwait(false); + return Response.FromValue(AnswersResult.FromResponse(response), response); + } + + /// Answers the specified question using your knowledge base. + /// The name of the project to use. + /// The name of the specific deployment of the project to use. + /// Post body of the request. + /// The cancellation token to use. + /// , or is null. + /// + public virtual Response GetAnswers(string projectName, string deploymentName, AnswersOptions knowledgeBaseQueryOptions, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(projectName, nameof(projectName)); + Argument.AssertNotNull(deploymentName, nameof(deploymentName)); + Argument.AssertNotNull(knowledgeBaseQueryOptions, nameof(knowledgeBaseQueryOptions)); + + using RequestContent content = knowledgeBaseQueryOptions.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAnswers(projectName, deploymentName, content, context); + return Response.FromValue(AnswersResult.FromResponse(response), response); + } + + /// + /// [Protocol Method] Answers the specified question using your knowledge base. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the project to use. + /// The name of the specific deployment of the project to use. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetAnswersAsync(string projectName, string deploymentName, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(projectName, nameof(projectName)); + Argument.AssertNotNull(deploymentName, nameof(deploymentName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("QuestionAnswering.GetAnswers"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAnswersRequest(projectName, deploymentName, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Answers the specified question using your knowledge base. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The name of the project to use. + /// The name of the specific deployment of the project to use. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetAnswers(string projectName, string deploymentName, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(projectName, nameof(projectName)); + Argument.AssertNotNull(deploymentName, nameof(deploymentName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("QuestionAnswering.GetAnswers"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAnswersRequest(projectName, deploymentName, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Answers the specified question using the provided text in the body. + /// Post body of the request. + /// The cancellation token to use. + /// is null. + /// + public virtual async Task> GetAnswersFromTextAsync(AnswersFromTextOptions textQueryOptions, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(textQueryOptions, nameof(textQueryOptions)); + + using RequestContent content = textQueryOptions.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAnswersFromTextAsync(content, context).ConfigureAwait(false); + return Response.FromValue(AnswersFromTextResult.FromResponse(response), response); + } + + /// Answers the specified question using the provided text in the body. + /// Post body of the request. + /// The cancellation token to use. + /// is null. + /// + public virtual Response GetAnswersFromText(AnswersFromTextOptions textQueryOptions, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(textQueryOptions, nameof(textQueryOptions)); + + using RequestContent content = textQueryOptions.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAnswersFromText(content, context); + return Response.FromValue(AnswersFromTextResult.FromResponse(response), response); + } + + /// + /// [Protocol Method] Answers the specified question using the provided text in the body. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetAnswersFromTextAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("QuestionAnswering.GetAnswersFromText"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAnswersFromTextRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Answers the specified question using the provided text in the body. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetAnswersFromText(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("QuestionAnswering.GetAnswersFromText"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAnswersFromTextRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateGetAnswersRequest(string projectName, string deploymentName, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/language", false); + uri.AppendPath("/:query-knowledgebases", false); + uri.AppendQuery("projectName", projectName, true); + uri.AppendQuery("deploymentName", deploymentName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetAnswersFromTextRequest(RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/language", false); + uri.AppendPath("/:query-text", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnsweringClient.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnsweringClient.cs new file mode 100644 index 000000000000..9a40fa3b7b52 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnsweringClient.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Language.QuestionAnswering +{ + // Data plane generated client. + /// + /// The language service API is a suite of natural language processing (NLP) skills + /// built with best-in-class Microsoft machine learning algorithms. The API can be + /// used to analyze unstructured text for tasks such as sentiment analysis, key + /// phrase extraction, language detection and question answering. Further + /// documentation can be found in <a + /// href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview">https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview</a>. + /// + public partial class QuestionAnsweringClient + { + private readonly AzureKeyCredential _keyCredential; + private static readonly string[] AuthorizationScopes = new string[] { "https://cognitiveservices.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// Initializes a new instance of QuestionAnswering. + /// The API version to use for this operation. + /// is null. + public virtual QuestionAnswering GetQuestionAnsweringClient(string apiVersion = "2023-04-01") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new QuestionAnswering(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint, apiVersion); + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnsweringClientExtensions.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnsweringClientExtensions.cs index 43465e18f14f..f67c7c04a2a2 100644 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnsweringClientExtensions.cs +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnsweringClientExtensions.cs @@ -8,31 +8,39 @@ using System; using Azure; using Azure.AI.Language.QuestionAnswering; -using Azure.AI.Language.QuestionAnswering.Authoring; using Azure.Core.Extensions; namespace Microsoft.Extensions.Azure { - /// Extension methods to add to client builder. + /// Extension methods to add to client builder. public static partial class QuestionAnsweringClientExtensions { - /// Registers a instance. + /// Registers a instance. /// The builder to register with. /// Supported Cognitive Services endpoint (e.g., https://<resource-name>.api.cognitiveservices.azure.com). /// A credential used to authenticate to an Azure Service. - public static IAzureClientBuilder AddQuestionAnsweringAuthoringClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential) + public static IAzureClientBuilder AddQuestionAnsweringClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential) where TBuilder : IAzureClientFactoryBuilder { - return builder.RegisterClientFactory((options) => new QuestionAnsweringAuthoringClient(endpoint, credential, options)); + return builder.RegisterClientFactory((options) => new QuestionAnsweringClient(endpoint, credential, options)); } - /// Registers a instance. + /// Registers a instance. + /// The builder to register with. + /// Supported Cognitive Services endpoint (e.g., https://<resource-name>.api.cognitiveservices.azure.com). + public static IAzureClientBuilder AddQuestionAnsweringClient(this TBuilder builder, Uri endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential + { + return builder.RegisterClientFactory((options, cred) => new QuestionAnsweringClient(endpoint, cred, options)); + } + + /// Registers a instance. /// The builder to register with. /// The configuration values. - public static IAzureClientBuilder AddQuestionAnsweringAuthoringClient(this TBuilder builder, TConfiguration configuration) + public static IAzureClientBuilder AddQuestionAnsweringClient(this TBuilder builder, TConfiguration configuration) where TBuilder : IAzureClientFactoryBuilderWithConfiguration { - return builder.RegisterClientFactory(configuration); + return builder.RegisterClientFactory(configuration); } } } diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnsweringModelFactory.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnsweringModelFactory.cs index c88aecc27ba2..1f9668a0bb78 100644 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnsweringModelFactory.cs +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnsweringModelFactory.cs @@ -13,26 +13,38 @@ namespace Azure.AI.Language.QuestionAnswering /// Model factory for models. public static partial class QuestionAnsweringModelFactory { - /// Initializes a new instance of . + /// Initializes a new instance of . + /// Previous turn top answer result QnA ID. + /// Previous user query. + /// A new instance for mocking. + public static KnowledgeBaseAnswerContext KnowledgeBaseAnswerContext(int previousQnaId = default, string previousQuestion = null) + { + return new KnowledgeBaseAnswerContext(previousQnaId, previousQuestion, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . /// Represents Answer Result list. - /// A new instance for mocking. + /// A new instance for mocking. public static AnswersResult AnswersResult(IEnumerable answers = null) { answers ??= new List(); - return new AnswersResult(answers?.ToList()); + return new AnswersResult(answers?.ToList(), serializedAdditionalRawData: null); } - /// Initializes a new instance of . + /// Initializes a new instance of . /// List of questions associated with the answer. /// Answer text. /// Answer confidence score, value ranges from 0 to 1. /// ID of the QnA result. /// Source of QnA result. - /// Metadata associated with the answer, useful to categorize or filter question answers. + /// + /// Metadata associated with the answer, useful to categorize or filter question + /// answers. + /// /// Dialog associated with Answer. /// Answer span object of QnA with respect to user's question. - /// A new instance for mocking. + /// A new instance for mocking. public static KnowledgeBaseAnswer KnowledgeBaseAnswer(IEnumerable questions = null, string answer = null, double? confidence = null, int? qnaId = null, string source = null, IReadOnlyDictionary metadata = null, KnowledgeBaseAnswerDialog dialog = null, AnswerSpan shortAnswer = null) { questions ??= new List(); @@ -46,59 +58,64 @@ public static KnowledgeBaseAnswer KnowledgeBaseAnswer(IEnumerable questi source, metadata, dialog, - shortAnswer); + shortAnswer, + serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// To mark if a prompt is relevant only with a previous question or not. If true, do not include this QnA as search result for queries without context; otherwise, if false, ignores context and includes this QnA in search result. + /// Initializes a new instance of . + /// + /// To mark if a prompt is relevant only with a previous question or not. If true, + /// do not include this QnA as search result for queries without context; + /// otherwise, if false, ignores context and includes this QnA in search result. + /// /// List of prompts associated with the answer. - /// A new instance for mocking. + /// A new instance for mocking. public static KnowledgeBaseAnswerDialog KnowledgeBaseAnswerDialog(bool? isContextOnly = null, IEnumerable prompts = null) { prompts ??= new List(); - return new KnowledgeBaseAnswerDialog(isContextOnly, prompts?.ToList()); + return new KnowledgeBaseAnswerDialog(isContextOnly, prompts?.ToList(), serializedAdditionalRawData: null); } - /// Initializes a new instance of . + /// Initializes a new instance of . /// Index of the prompt - used in ordering of the prompts. /// QnA ID corresponding to the prompt. /// Text displayed to represent a follow up question prompt. - /// A new instance for mocking. + /// A new instance for mocking. public static KnowledgeBaseAnswerPrompt KnowledgeBaseAnswerPrompt(int? displayOrder = null, int? qnaId = null, string displayText = null) { - return new KnowledgeBaseAnswerPrompt(displayOrder, qnaId, displayText); + return new KnowledgeBaseAnswerPrompt(displayOrder, qnaId, displayText, serializedAdditionalRawData: null); } - /// Initializes a new instance of . + /// Initializes a new instance of . /// Predicted text of answer span. /// Predicted score of answer span, value ranges from 0 to 1. /// The answer span offset from the start of answer. /// The length of the answer span. - /// A new instance for mocking. + /// A new instance for mocking. public static AnswerSpan AnswerSpan(string text = null, double? confidence = null, int? offset = null, int? length = null) { - return new AnswerSpan(text, confidence, offset, length); + return new AnswerSpan(text, confidence, offset, length, serializedAdditionalRawData: null); } - /// Initializes a new instance of . + /// Initializes a new instance of . /// Represents the answer results. - /// A new instance for mocking. + /// A new instance for mocking. public static AnswersFromTextResult AnswersFromTextResult(IEnumerable answers = null) { answers ??= new List(); - return new AnswersFromTextResult(answers?.ToList()); + return new AnswersFromTextResult(answers?.ToList(), serializedAdditionalRawData: null); } - /// Initializes a new instance of . + /// Initializes a new instance of . /// Answer. /// answer confidence score, value ranges from 0 to 1. /// record ID. /// Answer span object with respect to user's question. /// The sentence offset from the start of the document. /// The length of the sentence. - /// A new instance for mocking. + /// A new instance for mocking. public static TextAnswer TextAnswer(string answer = null, double? confidence = null, string id = null, AnswerSpan shortAnswer = null, int? offset = null, int? length = null) { return new TextAnswer( @@ -107,7 +124,8 @@ public static TextAnswer TextAnswer(string answer = null, double? confidence = n id, shortAnswer, offset, - length); + length, + serializedAdditionalRawData: null); } } } diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnsweringRestClient.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnsweringRestClient.cs deleted file mode 100644 index e542863840ee..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/QuestionAnsweringRestClient.cs +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.Pipeline; - -namespace Azure.AI.Language.QuestionAnswering -{ - internal partial class QuestionAnsweringRestClient - { - private readonly HttpPipeline _pipeline; - private readonly Uri _endpoint; - private readonly string _apiVersion; - - /// The ClientDiagnostics is used to provide tracing support for the client library. - internal ClientDiagnostics ClientDiagnostics { get; } - - /// Initializes a new instance of QuestionAnsweringRestClient. - /// The handler for diagnostic messaging in the client. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// Supported Cognitive Services endpoint (e.g., https://<resource-name>.api.cognitiveservices.azure.com). - /// Api Version. - /// , , or is null. - public QuestionAnsweringRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion = "2021-10-01") - { - ClientDiagnostics = clientDiagnostics ?? throw new ArgumentNullException(nameof(clientDiagnostics)); - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? throw new ArgumentNullException(nameof(endpoint)); - _apiVersion = apiVersion ?? throw new ArgumentNullException(nameof(apiVersion)); - } - - internal HttpMessage CreateGetAnswersRequest(string projectName, string deploymentName, AnswersOptions knowledgeBaseQueryOptions) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/language", false); - uri.AppendPath("/:query-knowledgebases", false); - uri.AppendQuery("projectName", projectName, true); - uri.AppendQuery("deploymentName", deploymentName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(knowledgeBaseQueryOptions); - request.Content = content; - return message; - } - - /// Answers the specified question using your knowledge base. - /// The name of the project to use. - /// The name of the specific deployment of the project to use. - /// Post body of the request. - /// The cancellation token to use. - /// , or is null. - public async Task> GetAnswersAsync(string projectName, string deploymentName, AnswersOptions knowledgeBaseQueryOptions, CancellationToken cancellationToken = default) - { - if (projectName == null) - { - throw new ArgumentNullException(nameof(projectName)); - } - if (deploymentName == null) - { - throw new ArgumentNullException(nameof(deploymentName)); - } - if (knowledgeBaseQueryOptions == null) - { - throw new ArgumentNullException(nameof(knowledgeBaseQueryOptions)); - } - - using var message = CreateGetAnswersRequest(projectName, deploymentName, knowledgeBaseQueryOptions); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - AnswersResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = AnswersResult.DeserializeAnswersResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Answers the specified question using your knowledge base. - /// The name of the project to use. - /// The name of the specific deployment of the project to use. - /// Post body of the request. - /// The cancellation token to use. - /// , or is null. - public Response GetAnswers(string projectName, string deploymentName, AnswersOptions knowledgeBaseQueryOptions, CancellationToken cancellationToken = default) - { - if (projectName == null) - { - throw new ArgumentNullException(nameof(projectName)); - } - if (deploymentName == null) - { - throw new ArgumentNullException(nameof(deploymentName)); - } - if (knowledgeBaseQueryOptions == null) - { - throw new ArgumentNullException(nameof(knowledgeBaseQueryOptions)); - } - - using var message = CreateGetAnswersRequest(projectName, deploymentName, knowledgeBaseQueryOptions); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - AnswersResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = AnswersResult.DeserializeAnswersResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal HttpMessage CreateGetAnswersFromTextRequest(AnswersFromTextOptions textQueryOptions) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRaw("/language", false); - uri.AppendPath("/:query-text", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(textQueryOptions); - request.Content = content; - return message; - } - - /// Answers the specified question using the provided text in the body. - /// Post body of the request. - /// The cancellation token to use. - /// is null. - public async Task> GetAnswersFromTextAsync(AnswersFromTextOptions textQueryOptions, CancellationToken cancellationToken = default) - { - if (textQueryOptions == null) - { - throw new ArgumentNullException(nameof(textQueryOptions)); - } - - using var message = CreateGetAnswersFromTextRequest(textQueryOptions); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - AnswersFromTextResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = AnswersFromTextResult.DeserializeAnswersFromTextResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Answers the specified question using the provided text in the body. - /// Post body of the request. - /// The cancellation token to use. - /// is null. - public Response GetAnswersFromText(AnswersFromTextOptions textQueryOptions, CancellationToken cancellationToken = default) - { - if (textQueryOptions == null) - { - throw new ArgumentNullException(nameof(textQueryOptions)); - } - - using var message = CreateGetAnswersFromTextRequest(textQueryOptions); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - AnswersFromTextResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = AnswersFromTextResult.DeserializeAnswersFromTextResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - } -} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/RankerKind.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/RankerKind.cs similarity index 100% rename from sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/RankerKind.cs rename to sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/RankerKind.cs diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/ShortAnswerOptions.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/ShortAnswerOptions.Serialization.cs new file mode 100644 index 000000000000..da1c6f7e00f4 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/ShortAnswerOptions.Serialization.cs @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering +{ + public partial class ShortAnswerOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ShortAnswerOptions)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("enable"u8); + writer.WriteBooleanValue(Enable); + if (Optional.IsDefined(ConfidenceThreshold)) + { + writer.WritePropertyName("confidenceScoreThreshold"u8); + writer.WriteNumberValue(ConfidenceThreshold.Value); + } + if (Optional.IsDefined(Size)) + { + writer.WritePropertyName("topAnswersWithSpan"u8); + writer.WriteNumberValue(Size.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ShortAnswerOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ShortAnswerOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeShortAnswerOptions(document.RootElement, options); + } + + internal static ShortAnswerOptions DeserializeShortAnswerOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool enable = default; + double? confidenceScoreThreshold = default; + int? topAnswersWithSpan = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("enable"u8)) + { + enable = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("confidenceScoreThreshold"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + confidenceScoreThreshold = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("topAnswersWithSpan"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + topAnswersWithSpan = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ShortAnswerOptions(enable, confidenceScoreThreshold, topAnswersWithSpan, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ShortAnswerOptions)} does not support writing '{options.Format}' format."); + } + } + + ShortAnswerOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeShortAnswerOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ShortAnswerOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ShortAnswerOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeShortAnswerOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/ShortAnswerOptions.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/ShortAnswerOptions.cs new file mode 100644 index 000000000000..99e793925557 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/ShortAnswerOptions.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering +{ + /// To configure Answer span prediction feature. + public partial class ShortAnswerOptions + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ShortAnswerOptions() + { + } + + /// Initializes a new instance of . + /// Enable or disable Answer Span prediction. + /// + /// Minimum threshold score required to include an answer span, value ranges from 0 + /// to 1. + /// + /// Number of Top answers to be considered for span prediction from 1 to 10. + /// Keeps track of any properties unknown to the library. + internal ShortAnswerOptions(bool enable, double? confidenceThreshold, int? size, IDictionary serializedAdditionalRawData) + { + Enable = enable; + ConfidenceThreshold = confidenceThreshold; + Size = size; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Minimum threshold score required to include an answer span, value ranges from 0 + /// to 1. + /// + public double? ConfidenceThreshold { get; set; } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/StringIndexType.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/StringIndexType.cs similarity index 68% rename from sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/StringIndexType.cs rename to sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/StringIndexType.cs index d186124abd83..d83e9250d5de 100644 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/StringIndexType.cs +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/StringIndexType.cs @@ -10,7 +10,11 @@ namespace Azure.AI.Language.QuestionAnswering { - /// Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. + /// + /// Specifies the method used to interpret string offsets. Defaults to Text + /// Elements (Graphemes) according to Unicode v8.0.0. For additional information + /// see https://aka.ms/text-analytics-offsets. + /// internal readonly partial struct StringIndexType : IEquatable { private readonly string _value; @@ -26,11 +30,24 @@ public StringIndexType(string value) private const string UnicodeCodePointValue = "UnicodeCodePoint"; private const string Utf16CodeUnitValue = "Utf16CodeUnit"; - /// Returned offset and length values will correspond to TextElements (Graphemes and Grapheme clusters) confirming to the Unicode 8.0.0 standard. Use this option if your application is written in .Net Framework or .Net Core and you will be using StringInfo. + /// + /// Returned offset and length values will correspond to TextElements (Graphemes + /// and Grapheme clusters) confirming to the Unicode 8.0.0 standard. Use this + /// option if your application is written in .Net Framework or .Net Core and you + /// will be using StringInfo. + /// public static StringIndexType TextElementsV8 { get; } = new StringIndexType(TextElementsV8Value); - /// Returned offset and length values will correspond to Unicode code points. Use this option if your application is written in a language that support Unicode, for example Python. + /// + /// Returned offset and length values will correspond to Unicode code points. Use + /// this option if your application is written in a language that support Unicode, + /// for example Python. + /// public static StringIndexType UnicodeCodePoint { get; } = new StringIndexType(UnicodeCodePointValue); - /// Returned offset and length values will correspond to UTF-16 code units. Use this option if your application is written in a language that support Unicode, for example Java, JavaScript. + /// + /// Returned offset and length values will correspond to UTF-16 code units. Use + /// this option if your application is written in a language that support Unicode, + /// for example Java, JavaScript. + /// public static StringIndexType Utf16CodeUnit { get; } = new StringIndexType(Utf16CodeUnitValue); /// Determines if two values are the same. public static bool operator ==(StringIndexType left, StringIndexType right) => left.Equals(right); diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/TextAnswer.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/TextAnswer.Serialization.cs new file mode 100644 index 000000000000..469317d6163f --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/TextAnswer.Serialization.cs @@ -0,0 +1,223 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering +{ + public partial class TextAnswer : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TextAnswer)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Answer)) + { + writer.WritePropertyName("answer"u8); + writer.WriteStringValue(Answer); + } + if (Optional.IsDefined(Confidence)) + { + writer.WritePropertyName("confidenceScore"u8); + writer.WriteNumberValue(Confidence.Value); + } + if (Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (Optional.IsDefined(ShortAnswer)) + { + writer.WritePropertyName("answerSpan"u8); + writer.WriteObjectValue(ShortAnswer, options); + } + if (Optional.IsDefined(Offset)) + { + writer.WritePropertyName("offset"u8); + writer.WriteNumberValue(Offset.Value); + } + if (Optional.IsDefined(Length)) + { + writer.WritePropertyName("length"u8); + writer.WriteNumberValue(Length.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TextAnswer IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TextAnswer)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTextAnswer(document.RootElement, options); + } + + internal static TextAnswer DeserializeTextAnswer(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string answer = default; + double? confidenceScore = default; + string id = default; + AnswerSpan answerSpan = default; + int? offset = default; + int? length = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("answer"u8)) + { + answer = property.Value.GetString(); + continue; + } + if (property.NameEquals("confidenceScore"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + confidenceScore = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("answerSpan"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + answerSpan = AnswerSpan.DeserializeAnswerSpan(property.Value, options); + continue; + } + if (property.NameEquals("offset"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + offset = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("length"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + length = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TextAnswer( + answer, + confidenceScore, + id, + answerSpan, + offset, + length, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TextAnswer)} does not support writing '{options.Format}' format."); + } + } + + TextAnswer IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTextAnswer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TextAnswer)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TextAnswer FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTextAnswer(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/TextAnswer.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/TextAnswer.cs similarity index 52% rename from sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/TextAnswer.cs rename to sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/TextAnswer.cs index 0b05741d01ee..df4180161112 100644 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/Models/TextAnswer.cs +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/TextAnswer.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.AI.Language.QuestionAnswering { /// Represents answer result. public partial class TextAnswer { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . internal TextAnswer() { @@ -22,7 +57,8 @@ internal TextAnswer() /// Answer span object with respect to user's question. /// The sentence offset from the start of the document. /// The length of the sentence. - internal TextAnswer(string answer, double? confidence, string id, AnswerSpan shortAnswer, int? offset, int? length) + /// Keeps track of any properties unknown to the library. + internal TextAnswer(string answer, double? confidence, string id, AnswerSpan shortAnswer, int? offset, int? length, IDictionary serializedAdditionalRawData) { Answer = answer; Confidence = confidence; @@ -30,6 +66,7 @@ internal TextAnswer(string answer, double? confidence, string id, AnswerSpan sho ShortAnswer = shortAnswer; Offset = offset; Length = length; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Answer. diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/TextDocument.Serialization.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/TextDocument.Serialization.cs new file mode 100644 index 000000000000..96b21ee10065 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/TextDocument.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Language.QuestionAnswering +{ + public partial class TextDocument : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TextDocument)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TextDocument IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TextDocument)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTextDocument(document.RootElement, options); + } + + internal static TextDocument DeserializeTextDocument(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string text = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TextDocument(id, text, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TextDocument)} does not support writing '{options.Format}' format."); + } + } + + TextDocument IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTextDocument(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TextDocument)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TextDocument FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTextDocument(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/TextDocument.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/TextDocument.cs new file mode 100644 index 000000000000..a7c7fd0179ce --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/Generated/TextDocument.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Language.QuestionAnswering +{ + /// Represent input text record to be queried. + public partial class TextDocument + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Unique identifier for the text record. + /// Text contents of the record. + /// Keeps track of any properties unknown to the library. + internal TextDocument(string id, string text, IDictionary serializedAdditionalRawData) + { + Id = id; + Text = text; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TextDocument() + { + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/autorest.md b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/autorest.md deleted file mode 100644 index 54b2f567ede9..000000000000 --- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/src/autorest.md +++ /dev/null @@ -1,134 +0,0 @@ -# Generated code configuration - -Run `dotnet build /t:GenerateCode` to generate code. - -``` yaml -# The title here is used to generate the single ClientOptions class name. -title: Question Answering -license-header: MICROSOFT_MIT_NO_VERSION - -batch: -- input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/59ad2b7dd63e952822aa51e11a26a0af5724f996/specification/cognitiveservices/data-plane/Language/stable/2021-10-01/questionanswering.json - clear-output-folder: true - model-namespace: false - generation1-convenience-client: true - -- input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/59ad2b7dd63e952822aa51e11a26a0af5724f996/specification/cognitiveservices/data-plane/Language/stable/2021-10-01/questionanswering-authoring.json - namespace: Azure.AI.Language.QuestionAnswering.Authoring - add-credentials: true - data-plane: true - keep-non-overloadable-protocol-signature: true - -modelerfour: - lenient-model-deduplication: true -``` - -## Customizations - -Customizations that should eventually be added to central autorest configuration. - -### General customizations - -Support automatically generating code for key credentials. - -``` yaml -directive: -# Support automatically generating code for key credentials. -- from: swagger-document - where: $.securityDefinitions - transform: | - $["AzureKey"] = $["apim_key"]; - delete $["apim_key"]; - -- from: swagger-document - where: $.security - transform: | - $ = [ - { - "AzureKey": [] - } - ]; - -# Fix Endpoint parameter description and format. -- from: swagger-document - where: $.parameters.Endpoint - transform: $["format"] = "url" - -# Update documentation. -- where-operation: QuestionAnsweringProjects_AddFeedback - transform: > - $["summary"] = "Add Active Learning feedback"; - -# Define HTTP 200 responses for LROs to document result model. -- where-operation: QuestionAnsweringProjects_DeployProject - transform: | - $.responses["200"] = { - description: "Project deployment details.", - schema: { - "$ref": "#/definitions/ProjectDeployment" - } - }; - -- where-operation: QuestionAnsweringProjects_Import - transform: | - $.responses["200"] = { - description: "Gets the status of an Import job.", - schema: { - "$ref": "#/definitions/JobState" - } - }; - -- where-operation: QuestionAnsweringProjects_UpdateQnas - transform: | - $["x-ms-pageable"] = { - "nextLinkName": "nextLink", - "itemName": "value" - }; - $.responses["200"] = { - description: "All the QnAs of a project.", - schema: { - "$ref": "#/definitions/QnaAssets" - } - }; - -- where-operation: QuestionAnsweringProjects_UpdateSources - transform: | - $["x-ms-pageable"] = { - "nextLinkName": "nextLink", - "itemName": "value" - }; - $.responses["200"] = { - description: "All the sources of a project.", - schema: { - "$ref": "#/definitions/QnaSources" - } - }; - -# Add links to REST documentation. Use any renamed operations preceeding this transform. -# BUGBUG: Cannot use where-operation-match: https://github.com/Azure/azure-sdk-for-net/issues/31451 -- from: questionanswering-authoring.json - where: $.paths.*.* - transform: | - var operationId = $.operationId.replace(/_/g, "/").replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(); - $["externalDocs"] = { - url: "https://learn.microsoft.com/rest/api/cognitiveservices/questionanswering/" + operationId - }; - -``` - -### C# customizations - -``` yaml -directive: -# Remove explicit paging parameters until Azure/azure-sdk-for-net#29342 is resolved. -- from: questionanswering-authoring.json - where: $.paths.*[?(@["x-ms-pageable"])] - transform: | - var paramRefs = [ - "common.json#/parameters/TopParameter", - "common.json#/parameters/SkipParameter", - "common.json#/parameters/MaxPageSizeParameter" - ]; - $.parameters = $.parameters.filter(param => !paramRefs.includes(param["$ref"])); - -``` diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/tests/Generated/Samples/Samples_QuestionAnswering.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/tests/Generated/Samples/Samples_QuestionAnswering.cs new file mode 100644 index 000000000000..ad57b4122551 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/tests/Generated/Samples/Samples_QuestionAnswering.cs @@ -0,0 +1,475 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AI.Language.QuestionAnswering.Samples +{ + public partial class Samples_QuestionAnswering + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnswering_GetAnswers_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + + using RequestContent content = RequestContent.Create(new object()); + Response response = client.GetAnswers("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnswering_GetAnswers_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + + using RequestContent content = RequestContent.Create(new object()); + Response response = await client.GetAnswersAsync("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnswering_GetAnswers_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + + AnswersOptions knowledgeBaseQueryOptions = new AnswersOptions(); + Response response = client.GetAnswers("", "", knowledgeBaseQueryOptions); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnswering_GetAnswers_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + + AnswersOptions knowledgeBaseQueryOptions = new AnswersOptions(); + Response response = await client.GetAnswersAsync("", "", knowledgeBaseQueryOptions); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnswering_GetAnswers_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + + using RequestContent content = RequestContent.Create(new + { + qnaId = 1234, + question = "", + top = 1234, + userId = "", + confidenceScoreThreshold = 123.45, + context = new + { + previousQnaId = 1234, + previousUserQuery = "", + }, + rankerType = "QuestionOnly", + filters = new + { + metadataFilter = new + { + metadata = new object[] + { +new +{ +key = "", +value = "", +} + }, + logicalOperation = "AND", + }, + sourceFilter = new object[] + { +"" + }, + logicalOperation = "AND", + }, + answerSpanRequest = new + { + enable = true, + confidenceScoreThreshold = 123.45, + topAnswersWithSpan = 1234, + }, + includeUnstructuredSources = true, + }); + Response response = client.GetAnswers("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("questions")[0].ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answer").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("confidenceScore").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("source").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("dialog").GetProperty("isContextOnly").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("dialog").GetProperty("prompts")[0].GetProperty("displayOrder").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qnaId").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("dialog").GetProperty("prompts")[0].GetProperty("displayText").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("text").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("confidenceScore").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("offset").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("length").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnswering_GetAnswers_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + + using RequestContent content = RequestContent.Create(new + { + qnaId = 1234, + question = "", + top = 1234, + userId = "", + confidenceScoreThreshold = 123.45, + context = new + { + previousQnaId = 1234, + previousUserQuery = "", + }, + rankerType = "QuestionOnly", + filters = new + { + metadataFilter = new + { + metadata = new object[] + { +new +{ +key = "", +value = "", +} + }, + logicalOperation = "AND", + }, + sourceFilter = new object[] + { +"" + }, + logicalOperation = "AND", + }, + answerSpanRequest = new + { + enable = true, + confidenceScoreThreshold = 123.45, + topAnswersWithSpan = 1234, + }, + includeUnstructuredSources = true, + }); + Response response = await client.GetAnswersAsync("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("questions")[0].ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answer").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("confidenceScore").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("source").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("dialog").GetProperty("isContextOnly").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("dialog").GetProperty("prompts")[0].GetProperty("displayOrder").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("dialog").GetProperty("prompts")[0].GetProperty("qnaId").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("dialog").GetProperty("prompts")[0].GetProperty("displayText").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("text").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("confidenceScore").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("offset").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("length").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnswering_GetAnswers_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + + AnswersOptions knowledgeBaseQueryOptions = new AnswersOptions + { + Size = 1234, + UserId = "", + ConfidenceThreshold = 123.45, + AnswerContext = new KnowledgeBaseAnswerContext(1234) + { + PreviousQuestion = "", + }, + RankerKind = RankerKind.QuestionOnly, + Filters = new QueryFilters + { + MetadataFilter = new MetadataFilter + { + Metadata = { new MetadataRecord("", "") }, + LogicalOperation = LogicalOperationKind.And, + }, + SourceFilter = { "" }, + LogicalOperation = LogicalOperationKind.And, + }, + ShortAnswerOptions = new ShortAnswerOptions + { + ConfidenceThreshold = 123.45, + Size = 1234, + }, + IncludeUnstructuredSources = true, + }; + Response response = client.GetAnswers("", "", knowledgeBaseQueryOptions); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnswering_GetAnswers_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + + AnswersOptions knowledgeBaseQueryOptions = new AnswersOptions + { + Size = 1234, + UserId = "", + ConfidenceThreshold = 123.45, + AnswerContext = new KnowledgeBaseAnswerContext(1234) + { + PreviousQuestion = "", + }, + RankerKind = RankerKind.QuestionOnly, + Filters = new QueryFilters + { + MetadataFilter = new MetadataFilter + { + Metadata = { new MetadataRecord("", "") }, + LogicalOperation = LogicalOperationKind.And, + }, + SourceFilter = { "" }, + LogicalOperation = LogicalOperationKind.And, + }, + ShortAnswerOptions = new ShortAnswerOptions + { + ConfidenceThreshold = 123.45, + Size = 1234, + }, + IncludeUnstructuredSources = true, + }; + Response response = await client.GetAnswersAsync("", "", knowledgeBaseQueryOptions); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnswering_GetAnswersFromText_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + + using RequestContent content = RequestContent.Create(new + { + question = "", + records = new object[] + { +new +{ +id = "", +text = "", +} + }, + }); + Response response = client.GetAnswersFromText(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnswering_GetAnswersFromText_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + + using RequestContent content = RequestContent.Create(new + { + question = "", + records = new object[] + { +new +{ +id = "", +text = "", +} + }, + }); + Response response = await client.GetAnswersFromTextAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnswering_GetAnswersFromText_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + + AnswersFromTextOptions textQueryOptions = new AnswersFromTextOptions("", new TextDocument[] + { +new TextDocument("", "") + }); + Response response = client.GetAnswersFromText(textQueryOptions); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnswering_GetAnswersFromText_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + + AnswersFromTextOptions textQueryOptions = new AnswersFromTextOptions("", new TextDocument[] + { +new TextDocument("", "") + }); + Response response = await client.GetAnswersFromTextAsync(textQueryOptions); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnswering_GetAnswersFromText_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + + using RequestContent content = RequestContent.Create(new + { + question = "", + records = new object[] + { +new +{ +id = "", +text = "", +} + }, + language = "", + stringIndexType = "TextElements_v8", + }); + Response response = client.GetAnswersFromText(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answer").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("confidenceScore").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("text").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("confidenceScore").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("offset").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("length").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("offset").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("length").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnswering_GetAnswersFromText_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + + using RequestContent content = RequestContent.Create(new + { + question = "", + records = new object[] + { +new +{ +id = "", +text = "", +} + }, + language = "", + stringIndexType = "TextElements_v8", + }); + Response response = await client.GetAnswersFromTextAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answer").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("confidenceScore").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("text").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("confidenceScore").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("offset").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("answerSpan").GetProperty("length").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("offset").ToString()); + Console.WriteLine(result.GetProperty("answers")[0].GetProperty("length").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_QuestionAnswering_GetAnswersFromText_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + + AnswersFromTextOptions textQueryOptions = new AnswersFromTextOptions("", new TextDocument[] + { +new TextDocument("", "") + }) + { + Language = "", + }; + Response response = client.GetAnswersFromText(textQueryOptions); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_QuestionAnswering_GetAnswersFromText_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + QuestionAnswering client = new QuestionAnsweringClient(endpoint, credential).GetQuestionAnsweringClient(apiVersion: "2023-04-01"); + + AnswersFromTextOptions textQueryOptions = new AnswersFromTextOptions("", new TextDocument[] + { +new TextDocument("", "") + }) + { + Language = "", + }; + Response response = await client.GetAnswersFromTextAsync(textQueryOptions); + } + } +} diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/tsp-location.yaml b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/tsp-location.yaml new file mode 100644 index 000000000000..f9de24692683 --- /dev/null +++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/cognitiveservices/Language.QuestionAnswering +commit: 84a9f8854055b954cb9544fa06b3d5713f414ea1 +repo: Azure/azure-rest-api-specs +additionalDirectories: