diff --git a/sdk/ai/Azure.AI.Projects.OneDP/Azure.AI.Projects.OneDP.sln b/sdk/ai/Azure.AI.Projects.OneDP/Azure.AI.Projects.OneDP.sln new file mode 100644 index 000000000000..2e995a88065d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/Azure.AI.Projects.OneDP.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.Projects.OneDP", "src\Azure.AI.Projects.OneDP.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.Projects.OneDP.Tests", "tests\Azure.AI.Projects.OneDP.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/ai/Azure.AI.Projects.OneDP/CHANGELOG.md b/sdk/ai/Azure.AI.Projects.OneDP/CHANGELOG.md new file mode 100644 index 000000000000..8b33f0fedccc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/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/ai/Azure.AI.Projects.OneDP/Directory.Build.props b/sdk/ai/Azure.AI.Projects.OneDP/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/ai/Azure.AI.Projects.OneDP/README.md b/sdk/ai/Azure.AI.Projects.OneDP/README.md new file mode 100644 index 000000000000..20b92c86af3c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/README.md @@ -0,0 +1,107 @@ +# Azure.AI.Projects.OneDP client library for .NET + +Azure.AI.Projects.OneDP 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/ai/Azure.AI.Projects.OneDP/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.Projects.OneDP --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/ai/Azure.AI.Projects.OneDP/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/ai/Azure.AI.Projects.OneDP/README.png) \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Azure.AI.Projects.OneDP.csproj b/sdk/ai/Azure.AI.Projects.OneDP/src/Azure.AI.Projects.OneDP.csproj new file mode 100644 index 000000000000..fe2c1d298c6c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Azure.AI.Projects.OneDP.csproj @@ -0,0 +1,20 @@ + + + This is the Azure.AI.Projects.OneDP client library for developing .NET applications with rich experience. + Azure SDK Code Generation Azure.AI.Projects.OneDP for Azure Data Plane + 1.0.0-beta.1 + Azure.AI.Projects.OneDP + $(RequiredTargetFrameworks) + true + + + + + + + + + + + + diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AIContent.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AIContent.Serialization.cs new file mode 100644 index 000000000000..6b6125dbfb7c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AIContent.Serialization.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Projects.OneDP +{ + [PersistableModelProxy(typeof(UnknownAIContent))] + public partial class AIContent : 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(AIContent)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + 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 + } + } + } + + AIContent 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(AIContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAIContent(document.RootElement, options); + } + + internal static AIContent DeserializeAIContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "audio": return AudioContent.DeserializeAudioContent(element, options); + case "contentFilter": return ContentFilterContent.DeserializeContentFilterContent(element, options); + case "file": return FileContent.DeserializeFileContent(element, options); + case "image": return ImageContent.DeserializeImageContent(element, options); + case "refusal": return RefusalContent.DeserializeRefusalContent(element, options); + case "text": return TextContent.DeserializeTextContent(element, options); + case "toolCall": return ToolCallContent.DeserializeToolCallContent(element, options); + case "toolResult": return ToolResultContent.DeserializeToolResultContent(element, options); + case "video": return VideoContent.DeserializeVideoContent(element, options); + } + } + return UnknownAIContent.DeserializeUnknownAIContent(element, options); + } + + 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(AIContent)} does not support writing '{options.Format}' format."); + } + } + + AIContent 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 DeserializeAIContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AIContent)} 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 AIContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAIContent(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/ai/Azure.AI.Projects.OneDP/src/Generated/AIContent.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AIContent.cs new file mode 100644 index 000000000000..9e8d4c9e3617 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AIContent.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.Projects.OneDP +{ + /// + /// An abstract representation of a structured content item within a chat message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + public abstract partial class AIContent + { + /// + /// 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 protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected AIContent() + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal AIContent(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets or sets the type. + internal string Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AIProjectClient.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AIProjectClient.cs new file mode 100644 index 000000000000..545e5383d672 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AIProjectClient.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Projects.OneDP +{ + // Data plane generated client. + /// The AIProject service client. + public partial class AIProjectClient + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + 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 AIProjectClient for mocking. + protected AIProjectClient() + { + } + + /// Initializes a new instance of AIProjectClient. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// A credential used to authenticate to an Azure Service. + /// or is null. + public AIProjectClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new AIProjectClientOptions()) + { + } + + /// Initializes a new instance of AIProjectClient. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// A credential used to authenticate to an Azure Service. + /// or is null. + public AIProjectClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new AIProjectClientOptions()) + { + } + + /// Initializes a new instance of AIProjectClient. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public AIProjectClient(Uri endpoint, AzureKeyCredential credential, AIProjectClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new AIProjectClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _keyCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader, AuthorizationApiKeyPrefix) }, new ResponseClassifier()); + _endpoint = endpoint; + } + + /// Initializes a new instance of AIProjectClient. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public AIProjectClient(Uri endpoint, TokenCredential credential, AIProjectClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new AIProjectClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _tokenCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier()); + _endpoint = endpoint; + } + + private ServicePatterns _cachedServicePatterns; + + /// Initializes a new instance of ServicePatterns. + public virtual ServicePatterns GetServicePatternsClient() + { + return Volatile.Read(ref _cachedServicePatterns) ?? Interlocked.CompareExchange(ref _cachedServicePatterns, new ServicePatterns(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint), null) ?? _cachedServicePatterns; + } + + /// Initializes a new instance of Messages. + /// The API version to use for this operation. + /// is null. + public virtual Messages GetMessagesClient(string apiVersion = "2025-05-01-preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new Messages(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of Conversations. + /// The API version to use for this operation. + /// is null. + public virtual Conversations GetConversationsClient(string apiVersion = "2025-05-01-preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new Conversations(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of Agents. + /// The API version to use for this operation. + /// is null. + public virtual Agents GetAgentsClient(string apiVersion = "2025-05-01-preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new Agents(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of Connections. + /// The API version to use for this operation. + /// is null. + public virtual Connections GetConnectionsClient(string apiVersion = "2025-05-01-preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new Connections(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of Evaluations. + /// The API version to use for this operation. + /// is null. + public virtual Evaluations GetEvaluationsClient(string apiVersion = "2025-05-01-preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new Evaluations(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of Datasets. + /// The API version to use for this operation. + /// is null. + public virtual Datasets GetDatasetsClient(string apiVersion = "2025-05-01-preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new Datasets(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of Indexes. + /// The API version to use for this operation. + /// is null. + public virtual Indexes GetIndexesClient(string apiVersion = "2025-05-01-preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new Indexes(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of Deployments. + /// The API version to use for this operation. + /// is null. + public virtual Deployments GetDeploymentsClient(string apiVersion = "2025-05-01-preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new Deployments(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint, apiVersion); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AIProjectClientOptions.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AIProjectClientOptions.cs new file mode 100644 index 000000000000..bcb9b80081a8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AIProjectClientOptions.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.Projects.OneDP +{ + /// Client options for AIProjectClient. + public partial class AIProjectClientOptions : ClientOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2025_05_01_Preview; + + /// The version of the service to use. + public enum ServiceVersion + { + /// Service version "2025-05-01-preview". + V2025_05_01_Preview = 1, + } + + internal string Version { get; } + + /// Initializes new instance of AIProjectClientOptions. + public AIProjectClientOptions(ServiceVersion version = LatestVersion) + { + Version = version switch + { + ServiceVersion.V2025_05_01_Preview => "2025-05-01-preview", + _ => throw new NotSupportedException() + }; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AIProjectsOneDPClientBuilderExtensions.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AIProjectsOneDPClientBuilderExtensions.cs new file mode 100644 index 000000000000..63f6f1a472cf --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AIProjectsOneDPClientBuilderExtensions.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.Projects.OneDP; +using Azure.Core.Extensions; + +namespace Microsoft.Extensions.Azure +{ + /// Extension methods to add to client builder. + public static partial class AIProjectsOneDPClientBuilderExtensions + { + /// Registers a instance. + /// The builder to register with. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// A credential used to authenticate to an Azure Service. + public static IAzureClientBuilder AddAIProjectClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential) + where TBuilder : IAzureClientFactoryBuilder + { + return builder.RegisterClientFactory((options) => new AIProjectClient(endpoint, credential, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + public static IAzureClientBuilder AddAIProjectClient(this TBuilder builder, Uri endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential + { + return builder.RegisterClientFactory((options, cred) => new AIProjectClient(endpoint, cred, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddAIProjectClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AIProjectsOneDPModelFactory.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AIProjectsOneDPModelFactory.cs new file mode 100644 index 000000000000..af5da0217328 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AIProjectsOneDPModelFactory.cs @@ -0,0 +1,686 @@ +// 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.Projects.OneDP +{ + /// Model factory for models. + public static partial class AIProjectsOneDPModelFactory + { + /// Initializes a new instance of . + /// The ID of the user who created the message (if applicable). + /// The ID of the agent who created the message (if applicable). + /// A unique identifier for this message. + /// A unique run ID, if this message was generated by a run process. + /// The conversation to which this message belongs. + /// The role of this message's author. + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// An optional display name for the author. + /// The timestamp (in Unix time) when this message was created. + /// The timestamp (in Unix time) when this message was completed, if applicable. + /// A new instance for mocking. + public static ChatMessage ChatMessage(string userId = null, string agentId = null, string messageId = null, string agentRunId = null, string conversationId = null, string role = null, IEnumerable content = null, string authorName = null, long? createdAt = null, long? completedAt = null) + { + content ??= new List(); + + return new UnknownChatMessage( + userId, + agentId, + messageId, + agentRunId, + conversationId, + role == null ? default : new AuthorRole(role), + content?.ToList(), + authorName, + createdAt, + completedAt, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The ID of the user who created the message (if applicable). + /// The ID of the agent who created the message (if applicable). + /// A unique identifier for this message. + /// A unique run ID, if this message was generated by a run process. + /// The conversation to which this message belongs. + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// An optional display name for the author. + /// The timestamp (in Unix time) when this message was created. + /// The timestamp (in Unix time) when this message was completed, if applicable. + /// A new instance for mocking. + public static UserMessage UserMessage(string userId = null, string agentId = null, string messageId = null, string agentRunId = null, string conversationId = null, IEnumerable content = null, string authorName = null, long? createdAt = null, long? completedAt = null) + { + content ??= new List(); + + return new UserMessage( + userId, + agentId, + messageId, + agentRunId, + conversationId, + AuthorRole.User, + content?.ToList(), + authorName, + createdAt, + completedAt, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The ID of the user who created the message (if applicable). + /// The ID of the agent who created the message (if applicable). + /// A unique identifier for this message. + /// A unique run ID, if this message was generated by a run process. + /// The conversation to which this message belongs. + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// An optional display name for the author. + /// The timestamp (in Unix time) when this message was created. + /// The timestamp (in Unix time) when this message was completed, if applicable. + /// A new instance for mocking. + public static DeveloperMessage DeveloperMessage(string userId = null, string agentId = null, string messageId = null, string agentRunId = null, string conversationId = null, IEnumerable content = null, string authorName = null, long? createdAt = null, long? completedAt = null) + { + content ??= new List(); + + return new DeveloperMessage( + userId, + agentId, + messageId, + agentRunId, + conversationId, + AuthorRole.Developer, + content?.ToList(), + authorName, + createdAt, + completedAt, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The ID of the user who created the message (if applicable). + /// The ID of the agent who created the message (if applicable). + /// A unique identifier for this message. + /// A unique run ID, if this message was generated by a run process. + /// The conversation to which this message belongs. + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// An optional display name for the author. + /// The timestamp (in Unix time) when this message was created. + /// The timestamp (in Unix time) when this message was completed, if applicable. + /// A new instance for mocking. + public static AgentMessage AgentMessage(string userId = null, string agentId = null, string messageId = null, string agentRunId = null, string conversationId = null, IEnumerable content = null, string authorName = null, long? createdAt = null, long? completedAt = null) + { + content ??= new List(); + + return new AgentMessage( + userId, + agentId, + messageId, + agentRunId, + conversationId, + AuthorRole.Agent, + content?.ToList(), + authorName, + createdAt, + completedAt, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The ID of the user who created the message (if applicable). + /// The ID of the agent who created the message (if applicable). + /// A unique identifier for this message. + /// A unique run ID, if this message was generated by a run process. + /// The conversation to which this message belongs. + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// An optional display name for the author. + /// The timestamp (in Unix time) when this message was created. + /// The timestamp (in Unix time) when this message was completed, if applicable. + /// A new instance for mocking. + public static SystemMessage SystemMessage(string userId = null, string agentId = null, string messageId = null, string agentRunId = null, string conversationId = null, IEnumerable content = null, string authorName = null, long? createdAt = null, long? completedAt = null) + { + content ??= new List(); + + return new SystemMessage( + userId, + agentId, + messageId, + agentRunId, + conversationId, + AuthorRole.System, + content?.ToList(), + authorName, + createdAt, + completedAt, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The ID of the user who created the message (if applicable). + /// The ID of the agent who created the message (if applicable). + /// A unique identifier for this message. + /// A unique run ID, if this message was generated by a run process. + /// The conversation to which this message belongs. + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// An optional display name for the author. + /// The timestamp (in Unix time) when this message was created. + /// The timestamp (in Unix time) when this message was completed, if applicable. + /// The ID of the tool call to which this result pertains. + /// A new instance for mocking. + public static ToolMessage ToolMessage(string userId = null, string agentId = null, string messageId = null, string agentRunId = null, string conversationId = null, IEnumerable content = null, string authorName = null, long? createdAt = null, long? completedAt = null, string toolCallId = null) + { + content ??= new List(); + + return new ToolMessage( + userId, + agentId, + messageId, + agentRunId, + conversationId, + AuthorRole.Tool, + content?.ToList(), + authorName, + createdAt, + completedAt, + serializedAdditionalRawData: null, + toolCallId); + } + + /// Initializes a new instance of . + /// A unique identifier for this conversation. + /// + /// A list of messages in this conversation. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// A new instance for mocking. + public static Conversation Conversation(string conversationId = null, IEnumerable messages = null) + { + messages ??= new List(); + + return new Conversation(conversationId, messages?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// A unique identifier for the agent. + /// A description of the agent; used for display purposes and to describe the agent. + /// Arbitrary metadata associated with this agent. + /// Configuration options for this agent. + /// A new instance for mocking. + public static Agent Agent(string agentId = null, string description = null, IDictionary metadata = null, AgentConfigurationOptions configurationOptions = null) + { + metadata ??= new Dictionary(); + + return new Agent(agentId, description, metadata, configurationOptions, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Unique identifier for this run. + /// Timestamp when the run was initiated (Unix time). + /// Timestamp when the run finished processing (Unix time). + /// The inputs that were used to start this run. + /// Identifier for the user making the request. + /// Flag indicating whether to store the run and associated messages. + /// Final status of the run request. Known values: 'inProgress', 'incomplete', 'cancelled', 'failed', 'completed' - or custom string. + /// + /// List of output messages generated by the agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// Token usage details for this run. + /// Details about why the response is incomplete, if applicable. + /// A new instance for mocking. + public static Run Run(string runId = null, long createdAt = default, long completedAt = default, RunInputs runInputs = null, string userId = null, bool? store = null, RunOutputsStatus status = default, IEnumerable output = null, CompletionUsage usage = null, RunIncompleteDetails incompleteDetails = null) + { + output ??= new List(); + + return new Run( + runId, + createdAt, + completedAt, + runInputs, + userId, + store, + status, + output?.ToList(), + usage, + incompleteDetails, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Unique identifier for the agent responsible for the run. This is optional (not needeed) when doing a run using ephemeral agent. + /// + /// The list of input messages for the run. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// Optional identifier for an existing conversation. + /// Optional metadata associated with the run request. + /// Optional configuration for run generation. + /// Identifier for the user making the request. + /// The agent configuration when not using a previously created agent. + /// A new instance for mocking. + public static RunInputs RunInputs(string agentId = null, IEnumerable input = null, string conversationId = null, IReadOnlyDictionary metadata = null, RunOptions options = null, string userId = null, AgentConfigurationOptions agentConfiguration = null) + { + input ??= new List(); + metadata ??= new Dictionary(); + + return new RunInputs( + agentId, + input?.ToList(), + conversationId, + metadata, + options, + userId, + agentConfiguration, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Number of run (completion) tokens used over the course of the run. + /// Number of prompt tokens used over the course of the run step. + /// Total number of tokens used (prompt + run). + /// Details of the prompt tokens. + /// Breakdown of tokens used in a run. + /// A new instance for mocking. + public static CompletionUsage CompletionUsage(long outputTokens = default, long inputTokens = default, long totalTokens = default, CompletionUsageInputTokenDetails inputTokenDetails = null, CompletionUsageOutputTokenDetails outputTokenDetails = null) + { + return new CompletionUsage( + outputTokens, + inputTokens, + totalTokens, + inputTokenDetails, + outputTokenDetails, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The number of cached prompt tokens. + /// A new instance for mocking. + public static CompletionUsageInputTokenDetails CompletionUsageInputTokenDetails(int? cachedTokens = null) + { + return new CompletionUsageInputTokenDetails(cachedTokens, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Tokens generated by the model for reasoning. + /// A new instance for mocking. + public static CompletionUsageOutputTokenDetails CompletionUsageOutputTokenDetails(int? reasoningTokens = null) + { + return new CompletionUsageOutputTokenDetails(reasoningTokens, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// A new instance for mocking. + public static RunIncompleteDetails RunIncompleteDetails(string reason = null) + { + return new RunIncompleteDetails(reason, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The name of the resource. + /// Category of the connection. + /// The connection URL to be used for this service. + /// Metadata of the connection. + /// A new instance for mocking. + public static Connection Connection(string name = null, ConnectionType type = default, string target = null, IReadOnlyDictionary metadata = null) + { + metadata ??= new Dictionary(); + + return new Connection(name, type, target, metadata, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Identifier of the evaluation. + /// + /// Data for evaluation. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + /// Display Name for evaluation. It helps to find the evaluation easily in AI Foundry. It does not need to be unique. + /// Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. + /// Status of the evaluation. It is set by service and is read-only. + /// Evaluation's tags. Unlike properties, tags are fully mutable. + /// Evaluation's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. + /// Evaluators to be used for the evaluation. + /// A new instance for mocking. + public static Evaluation Evaluation(string id = null, InputData data = null, string displayName = null, string description = null, string status = null, IDictionary tags = null, IDictionary properties = null, IDictionary evaluators = null) + { + tags ??= new Dictionary(); + properties ??= new Dictionary(); + evaluators ??= new Dictionary(); + + return new Evaluation( + id, + data, + displayName, + description, + status, + tags, + properties, + evaluators, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// [Required] Uri of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// Dataset type. + /// Indicates if dataset is reference only or managed by dataset service. If true, the underlying data will be deleted when the dataset version is deleted. + /// Asset stage. + /// A unique identifier for the asset, assetId probably?. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// A new instance for mocking. + public static DatasetVersion DatasetVersion(string datasetUri = null, string type = null, bool? isReference = null, string stage = null, string id = null, string name = null, string version = null, string description = null, IDictionary tags = null) + { + tags ??= new Dictionary(); + + return new UnknownDatasetVersion( + datasetUri, + type == null ? default : new DatasetType(type), + isReference, + stage, + id, + name, + version, + description, + tags, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// [Required] Uri of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// Indicates if dataset is reference only or managed by dataset service. If true, the underlying data will be deleted when the dataset version is deleted. + /// Asset stage. + /// A unique identifier for the asset, assetId probably?. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Indicates OpenAI Purpose. FileDatasets created with this field will be compatible with OpenAI-specific features. + /// A new instance for mocking. + public static FileDatasetVersion FileDatasetVersion(string datasetUri = null, bool? isReference = null, string stage = null, string id = null, string name = null, string version = null, string description = null, IDictionary tags = null, string openAIPurpose = null) + { + tags ??= new Dictionary(); + + return new FileDatasetVersion( + datasetUri, + DatasetType.UriFile, + isReference, + stage, + id, + name, + version, + description, + tags, + serializedAdditionalRawData: null, + openAIPurpose); + } + + /// Initializes a new instance of . + /// [Required] Uri of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// Indicates if dataset is reference only or managed by dataset service. If true, the underlying data will be deleted when the dataset version is deleted. + /// Asset stage. + /// A unique identifier for the asset, assetId probably?. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// A new instance for mocking. + public static FolderDatasetVersion FolderDatasetVersion(string datasetUri = null, bool? isReference = null, string stage = null, string id = null, string name = null, string version = null, string description = null, IDictionary tags = null) + { + tags ??= new Dictionary(); + + return new FolderDatasetVersion( + datasetUri, + DatasetType.UriFolder, + isReference, + stage, + id, + name, + version, + description, + tags, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// If PendingUploadId is not provided, a random GUID will be used. + /// Name of Azure blob storage connection to use for generating temporary SAS token. + /// TemporaryBlobReference is the only supported type. + /// A new instance for mocking. + public static PendingUploadRequest PendingUploadRequest(string pendingUploadId = null, string connectionName = null, PendingUploadType pendingUploadType = default) + { + return new PendingUploadRequest(pendingUploadId, connectionName, pendingUploadType, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Container-level read, write, list SAS. + /// ID for this upload request. + /// Version of dataset to be created if user did not specify version when initially creating upload. + /// TemporaryBlobReference is the only supported type. + /// A new instance for mocking. + public static PendingUploadResponse PendingUploadResponse(BlobReferenceForConsumption blobReferenceForConsumption = null, string pendingUploadId = null, string datasetVersion = null, PendingUploadType pendingUploadType = default) + { + return new PendingUploadResponse(blobReferenceForConsumption, pendingUploadId, datasetVersion, pendingUploadType, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Blob URI path for client to upload data. Example: https://blob.windows.core.net/Container/Path. + /// ARM ID of the storage account to use. + /// Credential info to access the storage account. + /// A new instance for mocking. + public static BlobReferenceForConsumption BlobReferenceForConsumption(string blobUri = null, string storageAccountArmId = null, SasCredential credential = null) + { + return new BlobReferenceForConsumption(blobUri, storageAccountArmId, credential, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// SAS Token. + /// A new instance for mocking. + public static SasCredential SasCredential(string sasToken = null) + { + return new SasCredential(CredentialType.SAS, serializedAdditionalRawData: null, sasToken); + } + + /// Initializes a new instance of . + /// API Key. + /// A new instance for mocking. + public static ApiKeyCredential ApiKeyCredential(string apiKey = null) + { + return new ApiKeyCredential(CredentialType.ApiKey, serializedAdditionalRawData: null, apiKey); + } + + /// Initializes a new instance of . + /// Type of index. + /// Asset stage. + /// A unique identifier for the asset, assetId probably?. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// A new instance for mocking. + public static Index Index(string type = null, string stage = null, string id = null, string name = null, string version = null, string description = null, IDictionary tags = null) + { + tags ??= new Dictionary(); + + return new UnknownIndex( + type == null ? default : new IndexType(type), + stage, + id, + name, + version, + description, + tags, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Asset stage. + /// A unique identifier for the asset, assetId probably?. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Name of connection to Azure AI Search. + /// Name of index in Azure AI Search resource to attach. + /// A new instance for mocking. + public static AzureAISearchIndex AzureAISearchIndex(string stage = null, string id = null, string name = null, string version = null, string description = null, IDictionary tags = null, string connectionName = null, string indexName = null) + { + tags ??= new Dictionary(); + + return new AzureAISearchIndex( + IndexType.AzureSearch, + stage, + id, + name, + version, + description, + tags, + serializedAdditionalRawData: null, + connectionName, + indexName); + } + + /// Initializes a new instance of . + /// Asset stage. + /// A unique identifier for the asset, assetId probably?. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Vector store id of managed index. + /// A new instance for mocking. + public static ManagedAzureAISearchIndex ManagedAzureAISearchIndex(string stage = null, string id = null, string name = null, string version = null, string description = null, IDictionary tags = null, string vectorStoreId = null) + { + tags ??= new Dictionary(); + + return new ManagedAzureAISearchIndex( + IndexType.ManagedAzureSearch, + stage, + id, + name, + version, + description, + tags, + serializedAdditionalRawData: null, + vectorStoreId); + } + + /// Initializes a new instance of . + /// Asset stage. + /// A unique identifier for the asset, assetId probably?. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Name of connection to CosmosDB. + /// Name of the CosmosDB Database. + /// Name of CosmosDB Container. + /// Embedding model configuration. + /// A new instance for mocking. + public static CosmosDBIndex CosmosDBIndex(string stage = null, string id = null, string name = null, string version = null, string description = null, IDictionary tags = null, string connectionName = null, string databaseName = null, string containerName = null, EmbeddingConfiguration embeddingConfiguration = null) + { + tags ??= new Dictionary(); + + return new CosmosDBIndex( + IndexType.CosmosDB, + stage, + id, + name, + version, + description, + tags, + serializedAdditionalRawData: null, + connectionName, + databaseName, + containerName, + embeddingConfiguration); + } + + /// Initializes a new instance of . + /// The type of the deployment. + /// Name of the deployment. + /// A new instance for mocking. + public static Deployment Deployment(string type = null, string name = null) + { + return new UnknownDeployment(type == null ? default : new DeploymentType(type), name, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Name of the deployment. + /// Publisher-specific name of the deployed model. + /// Publisher-specific version of the deployed model. + /// Name of the deployed model's publisher. + /// Capabilities of deployed model. + /// Sku of the model deployment. + /// Name of the connection the deployment comes from. + /// A new instance for mocking. + public static ModelDeployment ModelDeployment(string name = null, string modelName = null, string modelVersion = null, string modelPublisher = null, IReadOnlyDictionary capabilities = null, Sku sku = null, string connectionName = null) + { + capabilities ??= new Dictionary(); + + return new ModelDeployment( + DeploymentType.ModelDeployment, + name, + serializedAdditionalRawData: null, + modelName, + modelVersion, + modelPublisher, + capabilities, + sku, + connectionName); + } + + /// Initializes a new instance of . + /// Sku capacity. + /// Sku family. + /// Sku name. + /// Sku size. + /// Sku tier. + /// A new instance for mocking. + public static Sku Sku(long capacity = default, string family = null, string name = null, string size = null, string tier = null) + { + return new Sku( + capacity, + family, + name, + size, + tier, + serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AadCredential.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AadCredential.Serialization.cs new file mode 100644 index 000000000000..49a7ea9190df --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AadCredential.Serialization.cs @@ -0,0 +1,126 @@ +// 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.Projects.OneDP +{ + public partial class AadCredential : 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 override 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(AadCredential)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + AadCredential 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(AadCredential)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAadCredential(document.RootElement, options); + } + + internal static AadCredential DeserializeAadCredential(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CredentialType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new CredentialType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AadCredential(type, 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(AadCredential)} does not support writing '{options.Format}' format."); + } + } + + AadCredential 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 DeserializeAadCredential(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AadCredential)} 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 new AadCredential FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAadCredential(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AadCredential.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AadCredential.cs new file mode 100644 index 000000000000..aa13de098aeb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AadCredential.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// AAD Credential definition. + public partial class AadCredential : BaseCredential + { + /// Initializes a new instance of . + internal AadCredential() + { + Type = CredentialType.AAD; + } + + /// Initializes a new instance of . + /// Type of credential. Possible values are: AAD, SAS, ApiKey. + /// Keeps track of any properties unknown to the library. + internal AadCredential(CredentialType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Agent.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Agent.Serialization.cs new file mode 100644 index 000000000000..cb7f000c2376 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Agent.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.Projects.OneDP +{ + public partial class Agent : 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(Agent)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("agentId"u8); + writer.WriteStringValue(AgentId); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + 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(); + } + writer.WritePropertyName("configurationOptions"u8); + writer.WriteObjectValue(ConfigurationOptions, 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 + } + } + } + + Agent 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(Agent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgent(document.RootElement, options); + } + + internal static Agent DeserializeAgent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string agentId = default; + string description = default; + IDictionary metadata = default; + AgentConfigurationOptions configurationOptions = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("agentId"u8)) + { + agentId = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = 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("configurationOptions"u8)) + { + configurationOptions = AgentConfigurationOptions.DeserializeAgentConfigurationOptions(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Agent(agentId, description, metadata ?? new ChangeTrackingDictionary(), configurationOptions, 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(Agent)} does not support writing '{options.Format}' format."); + } + } + + Agent 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 DeserializeAgent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Agent)} 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 Agent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAgent(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/ai/Azure.AI.Projects.OneDP/src/Generated/Agent.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Agent.cs new file mode 100644 index 000000000000..d6945e4c3b1c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Agent.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Represents an AI agent with configuration, instructions, and tool access. + public partial class Agent + { + /// + /// 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 . + /// Configuration options for this agent. + /// is null. + public Agent(AgentConfigurationOptions configurationOptions) + { + Argument.AssertNotNull(configurationOptions, nameof(configurationOptions)); + + Metadata = new ChangeTrackingDictionary(); + ConfigurationOptions = configurationOptions; + } + + /// Initializes a new instance of . + /// A unique identifier for the agent. + /// A description of the agent; used for display purposes and to describe the agent. + /// Arbitrary metadata associated with this agent. + /// Configuration options for this agent. + /// Keeps track of any properties unknown to the library. + internal Agent(string agentId, string description, IDictionary metadata, AgentConfigurationOptions configurationOptions, IDictionary serializedAdditionalRawData) + { + AgentId = agentId; + Description = description; + Metadata = metadata; + ConfigurationOptions = configurationOptions; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Agent() + { + } + + /// A unique identifier for the agent. + public string AgentId { get; } + /// A description of the agent; used for display purposes and to describe the agent. + public string Description { get; set; } + /// Arbitrary metadata associated with this agent. + public IDictionary Metadata { get; } + /// Configuration options for this agent. + public AgentConfigurationOptions ConfigurationOptions { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentConfigurationOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentConfigurationOptions.Serialization.cs new file mode 100644 index 000000000000..71659b4feaee --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentConfigurationOptions.Serialization.cs @@ -0,0 +1,214 @@ +// 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.Projects.OneDP +{ + public partial class AgentConfigurationOptions : 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(AgentConfigurationOptions)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + if (Optional.IsDefined(AgentModel)) + { + writer.WritePropertyName("agentModel"u8); + writer.WriteObjectValue(AgentModel, options); + } + if (Optional.IsDefined(Instructions)) + { + writer.WritePropertyName("instructions"u8); + writer.WriteStringValue(Instructions); + } + if (Optional.IsCollectionDefined(Tools)) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in Tools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ToolChoice)) + { + writer.WritePropertyName("toolChoice"u8); + writer.WriteObjectValue(ToolChoice, 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 + } + } + } + + AgentConfigurationOptions 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(AgentConfigurationOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentConfigurationOptions(document.RootElement, options); + } + + internal static AgentConfigurationOptions DeserializeAgentConfigurationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string displayName = default; + AgentModel agentModel = default; + string instructions = default; + IList tools = default; + ToolChoiceBehavior toolChoice = 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("agentModel"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + agentModel = AgentModel.DeserializeAgentModel(property.Value, options); + continue; + } + if (property.NameEquals("instructions"u8)) + { + instructions = property.Value.GetString(); + continue; + } + if (property.NameEquals("tools"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AgentToolDefinition.DeserializeAgentToolDefinition(item, options)); + } + tools = array; + continue; + } + if (property.NameEquals("toolChoice"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + toolChoice = ToolChoiceBehavior.DeserializeToolChoiceBehavior(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AgentConfigurationOptions( + displayName, + agentModel, + instructions, + tools ?? new ChangeTrackingList(), + toolChoice, + 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(AgentConfigurationOptions)} does not support writing '{options.Format}' format."); + } + } + + AgentConfigurationOptions 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 DeserializeAgentConfigurationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentConfigurationOptions)} 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 AgentConfigurationOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAgentConfigurationOptions(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/ai/Azure.AI.Projects.OneDP/src/Generated/AgentConfigurationOptions.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentConfigurationOptions.cs new file mode 100644 index 000000000000..b402e1f667ce --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentConfigurationOptions.cs @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Options used when creating and an agent or completing a run without an existing agent. + public partial class AgentConfigurationOptions + { + /// + /// 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 display name of the agent; used for display purposes and sent to the LLM to identify the agent. + /// is null. + public AgentConfigurationOptions(string displayName) + { + Argument.AssertNotNull(displayName, nameof(displayName)); + + DisplayName = displayName; + Tools = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The display name of the agent; used for display purposes and sent to the LLM to identify the agent. + /// + /// The model definition for this agent. This is optional (not needed) when doing a run using persistent agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// Instructions provided to guide how this agent operates. + /// + /// A list of tool definitions available to the agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// + /// How the agent should choose among provided tools. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + /// Keeps track of any properties unknown to the library. + internal AgentConfigurationOptions(string displayName, AgentModel agentModel, string instructions, IList tools, ToolChoiceBehavior toolChoice, IDictionary serializedAdditionalRawData) + { + DisplayName = displayName; + AgentModel = agentModel; + Instructions = instructions; + Tools = tools; + ToolChoice = toolChoice; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AgentConfigurationOptions() + { + } + + /// The display name of the agent; used for display purposes and sent to the LLM to identify the agent. + public string DisplayName { get; set; } + /// + /// The model definition for this agent. This is optional (not needed) when doing a run using persistent agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public AgentModel AgentModel { get; set; } + /// Instructions provided to guide how this agent operates. + public string Instructions { get; set; } + /// + /// A list of tool definitions available to the agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + public IList Tools { get; } + /// + /// How the agent should choose among provided tools. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public ToolChoiceBehavior ToolChoice { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentMessage.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentMessage.Serialization.cs new file mode 100644 index 000000000000..7a680c927949 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentMessage.Serialization.cs @@ -0,0 +1,204 @@ +// 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.Projects.OneDP +{ + public partial class AgentMessage : 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 override 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(AgentMessage)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + AgentMessage 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(AgentMessage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentMessage(document.RootElement, options); + } + + internal static AgentMessage DeserializeAgentMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string userId = default; + string agentId = default; + string messageId = default; + string agentRunId = default; + string conversationId = default; + AuthorRole role = default; + IList content = default; + string authorName = default; + long? createdAt = default; + long? completedAt = 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("agentId"u8)) + { + agentId = property.Value.GetString(); + continue; + } + if (property.NameEquals("messageId"u8)) + { + messageId = property.Value.GetString(); + continue; + } + if (property.NameEquals("agentRunId"u8)) + { + agentRunId = property.Value.GetString(); + continue; + } + if (property.NameEquals("conversationId"u8)) + { + conversationId = property.Value.GetString(); + continue; + } + if (property.NameEquals("role"u8)) + { + role = new AuthorRole(property.Value.GetString()); + continue; + } + if (property.NameEquals("content"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AIContent.DeserializeAIContent(item, options)); + } + content = array; + continue; + } + if (property.NameEquals("authorName"u8)) + { + authorName = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdAt = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("completedAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + completedAt = property.Value.GetInt64(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AgentMessage( + userId, + agentId, + messageId, + agentRunId, + conversationId, + role, + content, + authorName, + createdAt, + completedAt, + 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(AgentMessage)} does not support writing '{options.Format}' format."); + } + } + + AgentMessage 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 DeserializeAgentMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentMessage)} 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 new AgentMessage FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAgentMessage(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentMessage.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentMessage.cs new file mode 100644 index 000000000000..d150d6cf5706 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentMessage.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// An agent message within a chat, always with the 'agent' role. + public partial class AgentMessage : ChatMessage + { + /// Initializes a new instance of . + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// is null. + public AgentMessage(IEnumerable content) : base(content) + { + Argument.AssertNotNull(content, nameof(content)); + + Role = AuthorRole.Agent; + } + + /// Initializes a new instance of . + /// The ID of the user who created the message (if applicable). + /// The ID of the agent who created the message (if applicable). + /// A unique identifier for this message. + /// A unique run ID, if this message was generated by a run process. + /// The conversation to which this message belongs. + /// The role of this message's author. + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// An optional display name for the author. + /// The timestamp (in Unix time) when this message was created. + /// The timestamp (in Unix time) when this message was completed, if applicable. + /// Keeps track of any properties unknown to the library. + internal AgentMessage(string userId, string agentId, string messageId, string agentRunId, string conversationId, AuthorRole role, IList content, string authorName, long? createdAt, long? completedAt, IDictionary serializedAdditionalRawData) : base(userId, agentId, messageId, agentRunId, conversationId, role, content, authorName, createdAt, completedAt, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal AgentMessage() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentModel.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentModel.Serialization.cs new file mode 100644 index 000000000000..80fa407dbc7d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentModel.Serialization.cs @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Projects.OneDP +{ + [PersistableModelProxy(typeof(UnknownAgentModel))] + public partial class AgentModel : 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(AgentModel)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + if (Optional.IsDefined(Provider)) + { + writer.WritePropertyName("provider"u8); + writer.WriteStringValue(Provider); + } + if (Optional.IsDefined(Endpoint)) + { + writer.WritePropertyName("endpoint"u8); + writer.WriteStringValue(Endpoint); + } + if (Optional.IsDefined(Options)) + { + writer.WritePropertyName("options"u8); + writer.WriteObjectValue(Options, 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 + } + } + } + + AgentModel 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(AgentModel)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentModel(document.RootElement, options); + } + + internal static AgentModel DeserializeAgentModel(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("provider", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "azure": return AzureAgentModel.DeserializeAzureAgentModel(element, options); + case "openai": return OpenAIAgentModel.DeserializeOpenAIAgentModel(element, options); + } + } + return UnknownAgentModel.DeserializeUnknownAgentModel(element, options); + } + + 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(AgentModel)} does not support writing '{options.Format}' format."); + } + } + + AgentModel 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 DeserializeAgentModel(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentModel)} 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 AgentModel FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAgentModel(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/ai/Azure.AI.Projects.OneDP/src/Generated/AgentModel.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentModel.cs new file mode 100644 index 000000000000..7676a51ef06e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentModel.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// + /// Represents the model or provider-specific data used by the agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public abstract partial class AgentModel + { + /// + /// 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 protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// A unique model or deployment ID for this agent model. + /// is null. + protected AgentModel(string id) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + } + + /// Initializes a new instance of . + /// A unique model or deployment ID for this agent model. + /// The name of the provider for this model (e.g., 'openai'). + /// An endpoint where the provider can be reached, if applicable. + /// Provider-specific configuration and options (JSON-like structure). + /// Keeps track of any properties unknown to the library. + internal AgentModel(string id, string provider, string endpoint, JSONAny options, IDictionary serializedAdditionalRawData) + { + Id = id; + Provider = provider; + Endpoint = endpoint; + Options = options; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AgentModel() + { + } + + /// A unique model or deployment ID for this agent model. + public string Id { get; set; } + /// The name of the provider for this model (e.g., 'openai'). + internal string Provider { get; set; } + /// An endpoint where the provider can be reached, if applicable. + public string Endpoint { get; set; } + /// Provider-specific configuration and options (JSON-like structure). + public JSONAny Options { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentToolDefinition.Serialization.cs new file mode 100644 index 000000000000..669334f0b924 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentToolDefinition.Serialization.cs @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Projects.OneDP +{ + [PersistableModelProxy(typeof(UnknownAgentToolDefinition))] + public partial class AgentToolDefinition : 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(AgentToolDefinition)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (Optional.IsDefined(Options)) + { + writer.WritePropertyName("options"u8); + writer.WriteObjectValue(Options, options); + } + if (Optional.IsDefined(Override)) + { + writer.WritePropertyName("override"u8); + writer.WriteObjectValue(Override, 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 + } + } + } + + AgentToolDefinition 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(AgentToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentToolDefinition(document.RootElement, options); + } + + internal static AgentToolDefinition DeserializeAgentToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "Function": return FunctionToolDefinition.DeserializeFunctionToolDefinition(element, options); + case "Microsoft.BingGrounding": return BingGroundingToolDefinition.DeserializeBingGroundingToolDefinition(element, options); + case "OpenAI.CodeInterpreter": return CodeInterpreterToolDefinition.DeserializeCodeInterpreterToolDefinition(element, options); + case "OpenAI.FileSearch": return FileSearchToolDefinition.DeserializeFileSearchToolDefinition(element, options); + case "OpenAI.OpenApi": return OpenApiToolDefinition.DeserializeOpenApiToolDefinition(element, options); + } + } + return UnknownAgentToolDefinition.DeserializeUnknownAgentToolDefinition(element, options); + } + + 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(AgentToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + AgentToolDefinition 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 DeserializeAgentToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentToolDefinition)} 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 AgentToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAgentToolDefinition(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/ai/Azure.AI.Projects.OneDP/src/Generated/AgentToolDefinition.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentToolDefinition.cs new file mode 100644 index 000000000000..e456c6b8b5d5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentToolDefinition.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.Projects.OneDP +{ + /// + /// Represents a definition of a tool that an agent may use, used in a polymorphic manner. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + public abstract partial class AgentToolDefinition + { + /// + /// 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 protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected AgentToolDefinition() + { + } + + /// Initializes a new instance of . + /// Discriminates the various child 'tool definition' types. + /// Additional options that specify the behavior of this tool (also polymorphic). + /// A set of overrides for the tool's name, description, or parameters. + /// Keeps track of any properties unknown to the library. + internal AgentToolDefinition(string type, AgentToolOptions options, AgentToolDefinitionOverride @override, IDictionary serializedAdditionalRawData) + { + Type = type; + Options = options; + Override = @override; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Discriminates the various child 'tool definition' types. + internal string Type { get; set; } + /// Additional options that specify the behavior of this tool (also polymorphic). + public AgentToolOptions Options { get; set; } + /// A set of overrides for the tool's name, description, or parameters. + public AgentToolDefinitionOverride Override { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentToolDefinitionOverride.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentToolDefinitionOverride.Serialization.cs new file mode 100644 index 000000000000..03f9caec5a7d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentToolDefinitionOverride.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.Projects.OneDP +{ + public partial class AgentToolDefinitionOverride : 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(AgentToolDefinitionOverride)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(Parameters)) + { + writer.WritePropertyName("parameters"u8); + writer.WriteObjectValue(Parameters, 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 + } + } + } + + AgentToolDefinitionOverride 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(AgentToolDefinitionOverride)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentToolDefinitionOverride(document.RootElement, options); + } + + internal static AgentToolDefinitionOverride DeserializeAgentToolDefinitionOverride(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string description = default; + JSONSchema parameters = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("parameters"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + parameters = JSONSchema.DeserializeJSONSchema(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AgentToolDefinitionOverride(name, description, parameters, 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(AgentToolDefinitionOverride)} does not support writing '{options.Format}' format."); + } + } + + AgentToolDefinitionOverride 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 DeserializeAgentToolDefinitionOverride(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentToolDefinitionOverride)} 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 AgentToolDefinitionOverride FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAgentToolDefinitionOverride(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/ai/Azure.AI.Projects.OneDP/src/Generated/AgentToolDefinitionOverride.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentToolDefinitionOverride.cs new file mode 100644 index 000000000000..3c82fcdea0d8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentToolDefinitionOverride.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.Projects.OneDP +{ + /// The AgentToolDefinitionOverride. + public partial class AgentToolDefinitionOverride + { + /// + /// 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 AgentToolDefinitionOverride() + { + } + + /// Initializes a new instance of . + /// An alternate name for the tool. + /// An alternate description for the tool. + /// An alternate JSON schema for the tool's parameters. + /// Keeps track of any properties unknown to the library. + internal AgentToolDefinitionOverride(string name, string description, JSONSchema parameters, IDictionary serializedAdditionalRawData) + { + Name = name; + Description = description; + Parameters = parameters; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// An alternate name for the tool. + public string Name { get; set; } + /// An alternate description for the tool. + public string Description { get; set; } + /// An alternate JSON schema for the tool's parameters. + public JSONSchema Parameters { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentToolOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentToolOptions.Serialization.cs new file mode 100644 index 000000000000..c71d61815178 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentToolOptions.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Projects.OneDP +{ + [PersistableModelProxy(typeof(UnknownAgentToolOptions))] + public partial class AgentToolOptions : 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(AgentToolOptions)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + 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 + } + } + } + + AgentToolOptions 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(AgentToolOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentToolOptions(document.RootElement, options); + } + + internal static AgentToolOptions DeserializeAgentToolOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + return UnknownAgentToolOptions.DeserializeUnknownAgentToolOptions(element, options); + } + + 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(AgentToolOptions)} does not support writing '{options.Format}' format."); + } + } + + AgentToolOptions 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 DeserializeAgentToolOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentToolOptions)} 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 AgentToolOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAgentToolOptions(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/ai/Azure.AI.Projects.OneDP/src/Generated/AgentToolOptions.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentToolOptions.cs new file mode 100644 index 000000000000..f3d0b526289d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AgentToolOptions.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.Projects.OneDP +{ + /// Base type for any agent tool-specific options, used in a polymorphic manner. + public abstract partial class AgentToolOptions + { + /// + /// 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 protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected AgentToolOptions() + { + } + + /// Initializes a new instance of . + /// Discriminates the various child 'tool options' types. + /// Keeps track of any properties unknown to the library. + internal AgentToolOptions(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Discriminates the various child 'tool options' types. + internal string Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Agents.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Agents.cs new file mode 100644 index 000000000000..8ed8aefca50a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Agents.cs @@ -0,0 +1,1368 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Projects.OneDP +{ + // Data plane generated sub-client. + /// + /// AGENTS + /// + /// Interface is rooted at /agents. + /// Includes standard resource operations + custom collection-level + /// and instance-level actions (complete, stream). + /// + public partial class Agents + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + 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 Agents for mocking. + protected Agents() + { + } + + /// Initializes a new instance of Agents. + /// 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. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// The API version to use for this operation. + internal Agents(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Creates a new Agent resource and returns it. + /// The display name of the agent; used for display purposes and sent to the LLM to identify the agent. + /// The model definition for this agent. This is optional (not needed) when doing a run using persistent agent. + /// Instructions provided to guide how this agent operates. + /// A list of tool definitions available to the agent. + /// How the agent should choose among provided tools. + /// The cancellation token to use. + /// is null. + /// + public virtual async Task> CreateAgentAsync(string displayName, AgentModel agentModel = null, string instructions = null, IEnumerable tools = null, ToolChoiceBehavior toolChoice = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(displayName, nameof(displayName)); + + CreateAgentRequest createAgentRequest = new CreateAgentRequest( + displayName, + agentModel, + instructions, + tools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + toolChoice, + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateAgentAsync(createAgentRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(Agent.FromResponse(response), response); + } + + /// Creates a new Agent resource and returns it. + /// The display name of the agent; used for display purposes and sent to the LLM to identify the agent. + /// The model definition for this agent. This is optional (not needed) when doing a run using persistent agent. + /// Instructions provided to guide how this agent operates. + /// A list of tool definitions available to the agent. + /// How the agent should choose among provided tools. + /// The cancellation token to use. + /// is null. + /// + public virtual Response CreateAgent(string displayName, AgentModel agentModel = null, string instructions = null, IEnumerable tools = null, ToolChoiceBehavior toolChoice = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(displayName, nameof(displayName)); + + CreateAgentRequest createAgentRequest = new CreateAgentRequest( + displayName, + agentModel, + instructions, + tools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + toolChoice, + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CreateAgent(createAgentRequest.ToRequestContent(), context); + return Response.FromValue(Agent.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates a new Agent resource and returns it. + /// + /// + /// + /// 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 CreateAgentAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Agents.CreateAgent"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateAgentRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates a new Agent resource and returns it. + /// + /// + /// + /// 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 CreateAgent(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Agents.CreateAgent"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateAgentRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieves an existing Agent by its ID. + /// The ID of the Agent to retrieve. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetAgentAsync(string agentId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentId, nameof(agentId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAgentAsync(agentId, context).ConfigureAwait(false); + return Response.FromValue(Agent.FromResponse(response), response); + } + + /// Retrieves an existing Agent by its ID. + /// The ID of the Agent to retrieve. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetAgent(string agentId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentId, nameof(agentId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAgent(agentId, context); + return Response.FromValue(Agent.FromResponse(response), response); + } + + /// + /// [Protocol Method] Retrieves an existing Agent by its ID. + /// + /// + /// + /// 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 ID of the Agent to retrieve. + /// 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 GetAgentAsync(string agentId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(agentId, nameof(agentId)); + + using var scope = ClientDiagnostics.CreateScope("Agents.GetAgent"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAgentRequest(agentId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Retrieves an existing Agent by its ID. + /// + /// + /// + /// 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 ID of the Agent to retrieve. + /// 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 GetAgent(string agentId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(agentId, nameof(agentId)); + + using var scope = ClientDiagnostics.CreateScope("Agents.GetAgent"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAgentRequest(agentId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Updates or replaces an agent and returns the updated resource. + /// The ID of the Agent to update. + /// The updated Agent data. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> UpdateAgentAsync(string agentId, Agent body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentId, nameof(agentId)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await UpdateAgentAsync(agentId, content, context).ConfigureAwait(false); + return Response.FromValue(Agent.FromResponse(response), response); + } + + /// Updates or replaces an agent and returns the updated resource. + /// The ID of the Agent to update. + /// The updated Agent data. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response UpdateAgent(string agentId, Agent body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentId, nameof(agentId)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = UpdateAgent(agentId, content, context); + return Response.FromValue(Agent.FromResponse(response), response); + } + + /// + /// [Protocol Method] Updates or replaces an agent and returns the updated resource. + /// + /// + /// + /// 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 ID of the Agent to update. + /// 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 UpdateAgentAsync(string agentId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(agentId, nameof(agentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Agents.UpdateAgent"); + scope.Start(); + try + { + using HttpMessage message = CreateUpdateAgentRequest(agentId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Updates or replaces an agent and returns the updated resource. + /// + /// + /// + /// 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 ID of the Agent to update. + /// 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 UpdateAgent(string agentId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(agentId, nameof(agentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Agents.UpdateAgent"); + scope.Start(); + try + { + using HttpMessage message = CreateUpdateAgentRequest(agentId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Deletes an Agent by its ID, returning 204 on success. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the Agent to delete. + /// 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 DeleteAgentAsync(string agentId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(agentId, nameof(agentId)); + + using var scope = ClientDiagnostics.CreateScope("Agents.DeleteAgent"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteAgentRequest(agentId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Deletes an Agent by its ID, returning 204 on success. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the Agent to delete. + /// 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 DeleteAgent(string agentId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(agentId, nameof(agentId)); + + using var scope = ClientDiagnostics.CreateScope("Agents.DeleteAgent"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteAgentRequest(agentId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Lists all Agents, returning an array of Agent objects. + /// The cancellation token to use. + /// + public virtual async Task>> GetAgentsAsync(CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAgentsAsync(context).ConfigureAwait(false); + IReadOnlyList value = default; + using var document = await JsonDocument.ParseAsync(response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + List array = new List(); + foreach (var item in document.RootElement.EnumerateArray()) + { + array.Add(Agent.DeserializeAgent(item)); + } + value = array; + return Response.FromValue(value, response); + } + + /// Lists all Agents, returning an array of Agent objects. + /// The cancellation token to use. + /// + public virtual Response> GetAgents(CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAgents(context); + IReadOnlyList value = default; + using var document = JsonDocument.Parse(response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + List array = new List(); + foreach (var item in document.RootElement.EnumerateArray()) + { + array.Add(Agent.DeserializeAgent(item)); + } + value = array; + return Response.FromValue(value, response); + } + + /// + /// [Protocol Method] Lists all Agents, returning an array of Agent objects. + /// + /// + /// + /// 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 request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetAgentsAsync(RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("Agents.GetAgents"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAgentsRequest(context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Lists all Agents, returning an array of Agent objects. + /// + /// + /// + /// 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 request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetAgents(RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("Agents.GetAgents"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAgentsRequest(context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates and waits for a run to finish, returning the completed Run (including its outputs). + /// The list of input messages for the run. + /// Unique identifier for the agent responsible for the run. This is optional (not needeed) when doing a run using ephemeral agent. + /// Optional identifier for an existing conversation. + /// Optional metadata associated with the run request. + /// Optional configuration for run generation. + /// Identifier for the user making the request. + /// The agent configuration when not using a previously created agent. + /// The cancellation token to use. + /// is null. + /// + public virtual async Task> RunAsync(IEnumerable input, string agentId = null, string conversationId = null, IReadOnlyDictionary metadata = null, RunOptions options = null, string userId = null, AgentConfigurationOptions agentConfiguration = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + RunRequest runRequest = new RunRequest( + agentId, + input.ToList(), + conversationId, + metadata ?? new ChangeTrackingDictionary(), + options, + userId, + agentConfiguration, + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await RunAsync(runRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(OneDP.Run.FromResponse(response), response); + } + + /// Creates and waits for a run to finish, returning the completed Run (including its outputs). + /// The list of input messages for the run. + /// Unique identifier for the agent responsible for the run. This is optional (not needeed) when doing a run using ephemeral agent. + /// Optional identifier for an existing conversation. + /// Optional metadata associated with the run request. + /// Optional configuration for run generation. + /// Identifier for the user making the request. + /// The agent configuration when not using a previously created agent. + /// The cancellation token to use. + /// is null. + /// + public virtual Response Run(IEnumerable input, string agentId = null, string conversationId = null, IReadOnlyDictionary metadata = null, RunOptions options = null, string userId = null, AgentConfigurationOptions agentConfiguration = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + RunRequest runRequest = new RunRequest( + agentId, + input.ToList(), + conversationId, + metadata ?? new ChangeTrackingDictionary(), + options, + userId, + agentConfiguration, + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = Run(runRequest.ToRequestContent(), context); + return Response.FromValue(OneDP.Run.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates and waits for a run to finish, returning the completed Run (including its outputs). + /// + /// + /// + /// 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 RunAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Agents.Run"); + scope.Start(); + try + { + using HttpMessage message = CreateRunRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates and waits for a run to finish, returning the completed Run (including its outputs). + /// + /// + /// + /// 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 Run(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Agents.Run"); + scope.Start(); + try + { + using HttpMessage message = CreateRunRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// The most basic operation. + /// The list of input messages for the run. + /// Unique identifier for the agent responsible for the run. This is optional (not needeed) when doing a run using ephemeral agent. + /// Optional identifier for an existing conversation. + /// Optional metadata associated with the run request. + /// Optional configuration for run generation. + /// Identifier for the user making the request. + /// The agent configuration when not using a previously created agent. + /// The cancellation token to use. + /// is null. + /// + public virtual async Task StreamAsync(IEnumerable input, string agentId = null, string conversationId = null, IReadOnlyDictionary metadata = null, RunOptions options = null, string userId = null, AgentConfigurationOptions agentConfiguration = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + StreamRequest streamRequest = new StreamRequest( + agentId, + input.ToList(), + conversationId, + metadata ?? new ChangeTrackingDictionary(), + options, + userId, + agentConfiguration, + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await StreamAsync(streamRequest.ToRequestContent(), context).ConfigureAwait(false); + return response; + } + + /// The most basic operation. + /// The list of input messages for the run. + /// Unique identifier for the agent responsible for the run. This is optional (not needeed) when doing a run using ephemeral agent. + /// Optional identifier for an existing conversation. + /// Optional metadata associated with the run request. + /// Optional configuration for run generation. + /// Identifier for the user making the request. + /// The agent configuration when not using a previously created agent. + /// The cancellation token to use. + /// is null. + /// + public virtual Response Stream(IEnumerable input, string agentId = null, string conversationId = null, IReadOnlyDictionary metadata = null, RunOptions options = null, string userId = null, AgentConfigurationOptions agentConfiguration = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + StreamRequest streamRequest = new StreamRequest( + agentId, + input.ToList(), + conversationId, + metadata ?? new ChangeTrackingDictionary(), + options, + userId, + agentConfiguration, + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = Stream(streamRequest.ToRequestContent(), context); + return response; + } + + /// + /// [Protocol Method] The most basic operation. + /// + /// + /// + /// 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 StreamAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Agents.Stream"); + scope.Start(); + try + { + using HttpMessage message = CreateStreamRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] The most basic operation. + /// + /// + /// + /// 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 Stream(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Agents.Stream"); + scope.Start(); + try + { + using HttpMessage message = CreateStreamRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Retrieves an existing run by its ID. + /// @route("/conversations/runs/{run_id}") + /// + /// Unique identifier for this run. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetRunAsync(string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetRunAsync(runId, context).ConfigureAwait(false); + return Response.FromValue(OneDP.Run.FromResponse(response), response); + } + + /// + /// Retrieves an existing run by its ID. + /// @route("/conversations/runs/{run_id}") + /// + /// Unique identifier for this run. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetRun(string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetRun(runId, context); + return Response.FromValue(OneDP.Run.FromResponse(response), response); + } + + /// + /// [Protocol Method] Retrieves an existing run by its ID. + /// @route("/conversations/runs/{run_id}") + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Unique identifier for this run. + /// 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 GetRunAsync(string runId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using var scope = ClientDiagnostics.CreateScope("Agents.GetRun"); + scope.Start(); + try + { + using HttpMessage message = CreateGetRunRequest(runId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Retrieves an existing run by its ID. + /// @route("/conversations/runs/{run_id}") + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Unique identifier for this run. + /// 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 GetRun(string runId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using var scope = ClientDiagnostics.CreateScope("Agents.GetRun"); + scope.Start(); + try + { + using HttpMessage message = CreateGetRunRequest(runId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Lists the inputs for a specific run by its ID. + /// The ID of the run. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetRunInputsAsync(string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetRunInputsAsync(runId, context).ConfigureAwait(false); + return Response.FromValue(RunInputs.FromResponse(response), response); + } + + /// Lists the inputs for a specific run by its ID. + /// The ID of the run. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetRunInputs(string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetRunInputs(runId, context); + return Response.FromValue(RunInputs.FromResponse(response), response); + } + + /// + /// [Protocol Method] Lists the inputs for a specific run by its ID. + /// + /// + /// + /// 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 ID of the run. + /// 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 GetRunInputsAsync(string runId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using var scope = ClientDiagnostics.CreateScope("Agents.GetRunInputs"); + scope.Start(); + try + { + using HttpMessage message = CreateGetRunInputsRequest(runId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Lists the inputs for a specific run by its ID. + /// + /// + /// + /// 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 ID of the run. + /// 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 GetRunInputs(string runId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using var scope = ClientDiagnostics.CreateScope("Agents.GetRunInputs"); + scope.Start(); + try + { + using HttpMessage message = CreateGetRunInputsRequest(runId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists all run records, each containing runInputs and runOutputs. + /// @route("/agents/runs") + /// + /// The cancellation token to use. + /// + public virtual AsyncPageable GetRunsAsync(CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetRunsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetRunsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => OneDP.Run.DeserializeRun(e), ClientDiagnostics, _pipeline, "Agents.GetRuns", "value", "nextLink", context); + } + + /// + /// Lists all run records, each containing runInputs and runOutputs. + /// @route("/agents/runs") + /// + /// The cancellation token to use. + /// + public virtual Pageable GetRuns(CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetRunsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetRunsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => OneDP.Run.DeserializeRun(e), ClientDiagnostics, _pipeline, "Agents.GetRuns", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Lists all run records, each containing runInputs and runOutputs. + /// @route("/agents/runs") + /// + /// + /// + /// 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 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 GetRunsAsync(RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetRunsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetRunsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Agents.GetRuns", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Lists all run records, each containing runInputs and runOutputs. + /// @route("/agents/runs") + /// + /// + /// + /// 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 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 GetRuns(RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetRunsRequest(context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetRunsNextPageRequest(nextLink, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Agents.GetRuns", "value", "nextLink", context); + } + + internal HttpMessage CreateCreateAgentRequest(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.AppendPath("/agents", 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; + } + + internal HttpMessage CreateGetAgentRequest(string agentId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/agents/", false); + uri.AppendPath(agentId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateUpdateAgentRequest(string agentId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/agents/", false); + uri.AppendPath(agentId, 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 CreateDeleteAgentRequest(string agentId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/agents/", false); + uri.AppendPath(agentId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetAgentsRequest(RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/agents", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateRunRequest(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.AppendPath("/conversations/runs", 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; + } + + internal HttpMessage CreateStreamRequest(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.AppendPath("/conversations/runs/stream", 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; + } + + internal HttpMessage CreateGetRunRequest(string runId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/runs/", false); + uri.AppendPath(runId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetRunsRequest(RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/runs", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetRunInputsRequest(string runId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/conversations/runs/", false); + uri.AppendPath(runId, true); + uri.AppendPath("/listInputs", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetRunsNextPageRequest(string nextLink, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + 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 }); + private static ResponseClassifier _responseClassifier204; + private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Annotations.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Annotations.Serialization.cs new file mode 100644 index 000000000000..069caac6ae71 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Annotations.Serialization.cs @@ -0,0 +1,212 @@ +// 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.Projects.OneDP +{ + public partial class Annotations : 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(Annotations)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (Optional.IsDefined(ToolCallId)) + { + writer.WritePropertyName("ToolCallId"u8); + writer.WriteStringValue(ToolCallId); + } + if (Optional.IsDefined(JsonPath)) + { + writer.WritePropertyName("jsonPath"u8); + writer.WriteStringValue(JsonPath); + } + if (Optional.IsDefined(Url)) + { + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url); + } + if (Optional.IsDefined(Start)) + { + writer.WritePropertyName("start"u8); + writer.WriteNumberValue(Start.Value); + } + if (Optional.IsDefined(End)) + { + writer.WritePropertyName("end"u8); + writer.WriteNumberValue(End.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 + } + } + } + + Annotations 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(Annotations)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAnnotations(document.RootElement, options); + } + + internal static Annotations DeserializeAnnotations(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + string toolCallId = default; + string jsonPath = default; + string url = default; + int? start = default; + int? end = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("ToolCallId"u8)) + { + toolCallId = property.Value.GetString(); + continue; + } + if (property.NameEquals("jsonPath"u8)) + { + jsonPath = property.Value.GetString(); + continue; + } + if (property.NameEquals("url"u8)) + { + url = property.Value.GetString(); + continue; + } + if (property.NameEquals("start"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + start = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("end"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + end = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Annotations( + type, + toolCallId, + jsonPath, + url, + start, + end, + 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(Annotations)} does not support writing '{options.Format}' format."); + } + } + + Annotations 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 DeserializeAnnotations(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Annotations)} 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 Annotations FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAnnotations(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/ai/Azure.AI.Projects.OneDP/src/Generated/Annotations.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Annotations.cs new file mode 100644 index 000000000000..7b1a3bc06cff --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Annotations.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Annotations applied to parts of the message or content. + public partial class Annotations + { + /// + /// 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 type of annotation. + /// is null. + public Annotations(string type) + { + Argument.AssertNotNull(type, nameof(type)); + + Type = type; + } + + /// Initializes a new instance of . + /// The type of annotation. + /// The tool call ID associated with the annotation. + /// The JSON path associated with the annotation. + /// The URL associated with the annotation. + /// The start position of the annotation. + /// The end position of the annotation. + /// Keeps track of any properties unknown to the library. + internal Annotations(string type, string toolCallId, string jsonPath, string url, int? start, int? end, IDictionary serializedAdditionalRawData) + { + Type = type; + ToolCallId = toolCallId; + JsonPath = jsonPath; + Url = url; + Start = start; + End = end; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Annotations() + { + } + + /// The type of annotation. + public string Type { get; set; } + /// The tool call ID associated with the annotation. + public string ToolCallId { get; set; } + /// The JSON path associated with the annotation. + public string JsonPath { get; set; } + /// The URL associated with the annotation. + public string Url { get; set; } + /// The start position of the annotation. + public int? Start { get; set; } + /// The end position of the annotation. + public int? End { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ApiKeyCredential.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ApiKeyCredential.Serialization.cs new file mode 100644 index 000000000000..49263a8c6fb9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ApiKeyCredential.Serialization.cs @@ -0,0 +1,137 @@ +// 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.Projects.OneDP +{ + public partial class ApiKeyCredential : 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 override 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(ApiKeyCredential)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (options.Format != "W") + { + writer.WritePropertyName("apiKey"u8); + writer.WriteStringValue(ApiKey); + } + } + + ApiKeyCredential 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(ApiKeyCredential)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeApiKeyCredential(document.RootElement, options); + } + + internal static ApiKeyCredential DeserializeApiKeyCredential(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string apiKey = default; + CredentialType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("apiKey"u8)) + { + apiKey = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new CredentialType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ApiKeyCredential(type, serializedAdditionalRawData, apiKey); + } + + 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(ApiKeyCredential)} does not support writing '{options.Format}' format."); + } + } + + ApiKeyCredential 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 DeserializeApiKeyCredential(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ApiKeyCredential)} 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 new ApiKeyCredential FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeApiKeyCredential(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ApiKeyCredential.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ApiKeyCredential.cs new file mode 100644 index 000000000000..9023a1d374fc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ApiKeyCredential.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// ApiKey Credential definition. + public partial class ApiKeyCredential : BaseCredential + { + /// Initializes a new instance of . + internal ApiKeyCredential() + { + Type = CredentialType.ApiKey; + } + + /// Initializes a new instance of . + /// Type of credential. Possible values are: AAD, SAS, ApiKey. + /// Keeps track of any properties unknown to the library. + /// API Key. + internal ApiKeyCredential(CredentialType type, IDictionary serializedAdditionalRawData, string apiKey) : base(type, serializedAdditionalRawData) + { + ApiKey = apiKey; + } + + /// API Key. + public string ApiKey { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AudioContent.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AudioContent.Serialization.cs new file mode 100644 index 000000000000..0175ee5e4a1a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AudioContent.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.Projects.OneDP +{ + public partial class AudioContent : 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 override 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(AudioContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Duration)) + { + writer.WritePropertyName("duration"u8); + writer.WriteObjectValue(Duration, options); + } + if (Optional.IsDefined(FileName)) + { + writer.WritePropertyName("fileName"u8); + writer.WriteStringValue(FileName); + } + if (Optional.IsDefined(MimeType)) + { + writer.WritePropertyName("mimeType"u8); + writer.WriteStringValue(MimeType); + } + if (Optional.IsDefined(Uri)) + { + writer.WritePropertyName("uri"u8); + writer.WriteStringValue(Uri.AbsoluteUri); + } + if (Optional.IsDefined(DataUri)) + { + writer.WritePropertyName("dataUri"u8); + writer.WriteStringValue(DataUri.AbsoluteUri); + } + if (Optional.IsDefined(Data)) + { + writer.WritePropertyName("data"u8); + writer.WriteBase64StringValue(Data.ToArray(), "D"); + } + } + + AudioContent 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(AudioContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAudioContent(document.RootElement, options); + } + + internal static AudioContent DeserializeAudioContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + object duration = default; + string fileName = default; + string mimeType = default; + Uri uri = default; + Uri dataUri = default; + BinaryData data = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("duration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + duration = property.Value.GetObject(); + continue; + } + if (property.NameEquals("fileName"u8)) + { + fileName = property.Value.GetString(); + continue; + } + if (property.NameEquals("mimeType"u8)) + { + mimeType = property.Value.GetString(); + continue; + } + if (property.NameEquals("uri"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + uri = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("dataUri"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataUri = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("data"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + data = BinaryData.FromBytes(property.Value.GetBytesFromBase64("D")); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AudioContent( + type, + serializedAdditionalRawData, + duration, + fileName, + mimeType, + uri, + dataUri, + data); + } + + 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(AudioContent)} does not support writing '{options.Format}' format."); + } + } + + AudioContent 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 DeserializeAudioContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AudioContent)} 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 new AudioContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAudioContent(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AudioContent.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AudioContent.cs new file mode 100644 index 000000000000..ea5cf09a43b5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AudioContent.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.Projects.OneDP +{ + /// A structured chat content item containing an audio reference. + public partial class AudioContent : AIContent + { + /// Initializes a new instance of . + public AudioContent() + { + Type = "audio"; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// Duration of audio in seconds (optional). + /// The file name for this binary content. + /// The MIME type for this binary content. + /// URI where the binary content can be retrieved. + /// Data URI containing the binary content inlined. + /// Raw bytes for the binary content. + internal AudioContent(string type, IDictionary serializedAdditionalRawData, object duration, string fileName, string mimeType, Uri uri, Uri dataUri, BinaryData data) : base(type, serializedAdditionalRawData) + { + Duration = duration; + FileName = fileName; + MimeType = mimeType; + Uri = uri; + DataUri = dataUri; + Data = data; + } + + /// Duration of audio in seconds (optional). + public object Duration { get; set; } + /// The file name for this binary content. + public string FileName { get; set; } + /// The MIME type for this binary content. + public string MimeType { get; set; } + /// URI where the binary content can be retrieved. + public Uri Uri { get; set; } + /// Data URI containing the binary content inlined. + public Uri DataUri { get; set; } + /// + /// Raw bytes for the binary content. + /// + /// To assign a byte[] to this property use . + /// The byte[] will be serialized to a Base64 encoded string. + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromBytes(new byte[] { 1, 2, 3 }) + /// Creates a payload of "AQID". + /// + /// + /// + /// + public BinaryData Data { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AuthorRole.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AuthorRole.cs new file mode 100644 index 000000000000..c54ff478a093 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AuthorRole.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.Projects.OneDP +{ + /// Possible roles of the message author. + internal readonly partial struct AuthorRole : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AuthorRole(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UserValue = "user"; + private const string AgentValue = "agent"; + private const string SystemValue = "system"; + private const string ToolValue = "tool"; + private const string DeveloperValue = "developer"; + + /// user. + public static AuthorRole User { get; } = new AuthorRole(UserValue); + /// agent. + public static AuthorRole Agent { get; } = new AuthorRole(AgentValue); + /// system. + public static AuthorRole System { get; } = new AuthorRole(SystemValue); + /// tool. + public static AuthorRole Tool { get; } = new AuthorRole(ToolValue); + /// developer. + public static AuthorRole Developer { get; } = new AuthorRole(DeveloperValue); + /// Determines if two values are the same. + public static bool operator ==(AuthorRole left, AuthorRole right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AuthorRole left, AuthorRole right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AuthorRole(string value) => new AuthorRole(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AuthorRole other && Equals(other); + /// + public bool Equals(AuthorRole 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/ai/Azure.AI.Projects.OneDP/src/Generated/AutoToolChoiceBehavior.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AutoToolChoiceBehavior.Serialization.cs new file mode 100644 index 000000000000..3de1e9738ea1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AutoToolChoiceBehavior.Serialization.cs @@ -0,0 +1,144 @@ +// 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.Projects.OneDP +{ + public partial class AutoToolChoiceBehavior : 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 override 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(AutoToolChoiceBehavior)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("toolNames"u8); + writer.WriteStartArray(); + foreach (var item in ToolNames) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + + AutoToolChoiceBehavior 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(AutoToolChoiceBehavior)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAutoToolChoiceBehavior(document.RootElement, options); + } + + internal static AutoToolChoiceBehavior DeserializeAutoToolChoiceBehavior(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList toolNames = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("toolNames"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + toolNames = array; + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AutoToolChoiceBehavior(type, serializedAdditionalRawData, toolNames); + } + + 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(AutoToolChoiceBehavior)} does not support writing '{options.Format}' format."); + } + } + + AutoToolChoiceBehavior 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 DeserializeAutoToolChoiceBehavior(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AutoToolChoiceBehavior)} 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 new AutoToolChoiceBehavior FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAutoToolChoiceBehavior(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AutoToolChoiceBehavior.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AutoToolChoiceBehavior.cs new file mode 100644 index 000000000000..cb0a41147e1f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AutoToolChoiceBehavior.cs @@ -0,0 +1,45 @@ +// 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.Projects.OneDP +{ + /// Behavior specifying an automatic choice among the given tools. + public partial class AutoToolChoiceBehavior : ToolChoiceBehavior + { + /// Initializes a new instance of . + /// The tool names from which the agent can automatically choose. + /// is null. + public AutoToolChoiceBehavior(IEnumerable toolNames) + { + Argument.AssertNotNull(toolNames, nameof(toolNames)); + + Type = "auto"; + ToolNames = toolNames.ToList(); + } + + /// Initializes a new instance of . + /// The kind of tool-choice strategy. + /// Keeps track of any properties unknown to the library. + /// The tool names from which the agent can automatically choose. + internal AutoToolChoiceBehavior(string type, IDictionary serializedAdditionalRawData, IList toolNames) : base(type, serializedAdditionalRawData) + { + ToolNames = toolNames; + } + + /// Initializes a new instance of for deserialization. + internal AutoToolChoiceBehavior() + { + } + + /// The tool names from which the agent can automatically choose. + public IList ToolNames { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AzureAISearchIndex.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AzureAISearchIndex.Serialization.cs new file mode 100644 index 000000000000..32b697535785 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AzureAISearchIndex.Serialization.cs @@ -0,0 +1,197 @@ +// 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.Projects.OneDP +{ + public partial class AzureAISearchIndex : 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 override 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(AzureAISearchIndex)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("connectionName"u8); + writer.WriteStringValue(ConnectionName); + writer.WritePropertyName("indexName"u8); + writer.WriteStringValue(IndexName); + } + + AzureAISearchIndex 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(AzureAISearchIndex)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureAISearchIndex(document.RootElement, options); + } + + internal static AzureAISearchIndex DeserializeAzureAISearchIndex(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string connectionName = default; + string indexName = default; + IndexType type = default; + string stage = default; + string id = default; + string name = default; + string version = default; + string description = default; + IDictionary tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("connectionName"u8)) + { + connectionName = property.Value.GetString(); + continue; + } + if (property.NameEquals("indexName"u8)) + { + indexName = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new IndexType(property.Value.GetString()); + continue; + } + if (property.NameEquals("stage"u8)) + { + stage = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("version"u8)) + { + version = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"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()); + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AzureAISearchIndex( + type, + stage, + id, + name, + version, + description, + tags ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData, + connectionName, + indexName); + } + + 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(AzureAISearchIndex)} does not support writing '{options.Format}' format."); + } + } + + AzureAISearchIndex 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 DeserializeAzureAISearchIndex(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureAISearchIndex)} 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 new AzureAISearchIndex FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAzureAISearchIndex(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AzureAISearchIndex.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AzureAISearchIndex.cs new file mode 100644 index 000000000000..f386432d38b9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AzureAISearchIndex.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Azure AI Search Index Definition. + public partial class AzureAISearchIndex : Index + { + /// Initializes a new instance of . + /// Name of connection to Azure AI Search. + /// Name of index in Azure AI Search resource to attach. + /// or is null. + public AzureAISearchIndex(string connectionName, string indexName) + { + Argument.AssertNotNull(connectionName, nameof(connectionName)); + Argument.AssertNotNull(indexName, nameof(indexName)); + + Type = IndexType.AzureSearch; + ConnectionName = connectionName; + IndexName = indexName; + } + + /// Initializes a new instance of . + /// Type of index. + /// Asset stage. + /// A unique identifier for the asset, assetId probably?. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Keeps track of any properties unknown to the library. + /// Name of connection to Azure AI Search. + /// Name of index in Azure AI Search resource to attach. + internal AzureAISearchIndex(IndexType type, string stage, string id, string name, string version, string description, IDictionary tags, IDictionary serializedAdditionalRawData, string connectionName, string indexName) : base(type, stage, id, name, version, description, tags, serializedAdditionalRawData) + { + ConnectionName = connectionName; + IndexName = indexName; + } + + /// Initializes a new instance of for deserialization. + internal AzureAISearchIndex() + { + } + + /// Name of connection to Azure AI Search. + public string ConnectionName { get; set; } + /// Name of index in Azure AI Search resource to attach. + public string IndexName { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AzureAgentModel.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AzureAgentModel.Serialization.cs new file mode 100644 index 000000000000..7a93c4b03f02 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AzureAgentModel.Serialization.cs @@ -0,0 +1,148 @@ +// 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.Projects.OneDP +{ + public partial class AzureAgentModel : 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 override 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(AzureAgentModel)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + AzureAgentModel 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(AzureAgentModel)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureAgentModel(document.RootElement, options); + } + + internal static AzureAgentModel DeserializeAzureAgentModel(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string provider = default; + string endpoint = default; + JSONAny options0 = 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("provider"u8)) + { + provider = property.Value.GetString(); + continue; + } + if (property.NameEquals("endpoint"u8)) + { + endpoint = property.Value.GetString(); + continue; + } + if (property.NameEquals("options"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + options0 = JSONAny.DeserializeJSONAny(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AzureAgentModel(id, provider, endpoint, options0, 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(AzureAgentModel)} does not support writing '{options.Format}' format."); + } + } + + AzureAgentModel 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 DeserializeAzureAgentModel(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureAgentModel)} 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 new AzureAgentModel FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAzureAgentModel(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AzureAgentModel.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AzureAgentModel.cs new file mode 100644 index 000000000000..3b4bf46aa619 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/AzureAgentModel.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// A specialized AgentModel for Azure-based providers. + public partial class AzureAgentModel : AgentModel + { + /// Initializes a new instance of . + /// A unique model or deployment ID for this agent model. + /// is null. + public AzureAgentModel(string id) : base(id) + { + Argument.AssertNotNull(id, nameof(id)); + + Provider = "azure"; + } + + /// Initializes a new instance of . + /// A unique model or deployment ID for this agent model. + /// The name of the provider for this model (e.g., 'openai'). + /// An endpoint where the provider can be reached, if applicable. + /// Provider-specific configuration and options (JSON-like structure). + /// Keeps track of any properties unknown to the library. + internal AzureAgentModel(string id, string provider, string endpoint, JSONAny options, IDictionary serializedAdditionalRawData) : base(id, provider, endpoint, options, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal AzureAgentModel() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/BaseCredential.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/BaseCredential.Serialization.cs new file mode 100644 index 000000000000..d1396ac48a7a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/BaseCredential.Serialization.cs @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Projects.OneDP +{ + [PersistableModelProxy(typeof(UnknownBaseCredential))] + public partial class BaseCredential : 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(BaseCredential)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.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 + } + } + } + + BaseCredential 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(BaseCredential)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBaseCredential(document.RootElement, options); + } + + internal static BaseCredential DeserializeBaseCredential(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "AAD": return AadCredential.DeserializeAadCredential(element, options); + case "ApiKey": return ApiKeyCredential.DeserializeApiKeyCredential(element, options); + case "SAS": return SasCredential.DeserializeSasCredential(element, options); + } + } + return UnknownBaseCredential.DeserializeUnknownBaseCredential(element, options); + } + + 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(BaseCredential)} does not support writing '{options.Format}' format."); + } + } + + BaseCredential 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 DeserializeBaseCredential(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BaseCredential)} 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 BaseCredential FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBaseCredential(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/ai/Azure.AI.Projects.OneDP/src/Generated/BaseCredential.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/BaseCredential.cs new file mode 100644 index 000000000000..6d41ee4501b0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/BaseCredential.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.Projects.OneDP +{ + /// + /// Base Credential definition + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public abstract partial class BaseCredential + { + /// + /// 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 protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected BaseCredential() + { + } + + /// Initializes a new instance of . + /// Type of credential. Possible values are: AAD, SAS, ApiKey. + /// Keeps track of any properties unknown to the library. + internal BaseCredential(CredentialType type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Type of credential. Possible values are: AAD, SAS, ApiKey. + internal CredentialType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/BingGroundingToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/BingGroundingToolDefinition.Serialization.cs new file mode 100644 index 000000000000..b88706c86784 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/BingGroundingToolDefinition.Serialization.cs @@ -0,0 +1,154 @@ +// 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.Projects.OneDP +{ + public partial class BingGroundingToolDefinition : 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 override 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(BingGroundingToolDefinition)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("connectionName"u8); + writer.WriteStringValue(ConnectionName); + } + + BingGroundingToolDefinition 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(BingGroundingToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBingGroundingToolDefinition(document.RootElement, options); + } + + internal static BingGroundingToolDefinition DeserializeBingGroundingToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string connectionName = default; + string type = default; + AgentToolOptions options0 = default; + AgentToolDefinitionOverride @override = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("connectionName"u8)) + { + connectionName = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("options"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + options0 = AgentToolOptions.DeserializeAgentToolOptions(property.Value, options); + continue; + } + if (property.NameEquals("override"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + @override = AgentToolDefinitionOverride.DeserializeAgentToolDefinitionOverride(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BingGroundingToolDefinition(type, options0, @override, serializedAdditionalRawData, connectionName); + } + + 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(BingGroundingToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + BingGroundingToolDefinition 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 DeserializeBingGroundingToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BingGroundingToolDefinition)} 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 new BingGroundingToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBingGroundingToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/BingGroundingToolDefinition.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/BingGroundingToolDefinition.cs new file mode 100644 index 000000000000..d13be1804a84 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/BingGroundingToolDefinition.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// A tool definition for Microsoft Bing grounding. + public partial class BingGroundingToolDefinition : AgentToolDefinition + { + /// Initializes a new instance of . + /// The name of the Bing grounding connection. + /// is null. + public BingGroundingToolDefinition(string connectionName) + { + Argument.AssertNotNull(connectionName, nameof(connectionName)); + + Type = "Microsoft.BingGrounding"; + ConnectionName = connectionName; + } + + /// Initializes a new instance of . + /// Discriminates the various child 'tool definition' types. + /// Additional options that specify the behavior of this tool (also polymorphic). + /// A set of overrides for the tool's name, description, or parameters. + /// Keeps track of any properties unknown to the library. + /// The name of the Bing grounding connection. + internal BingGroundingToolDefinition(string type, AgentToolOptions options, AgentToolDefinitionOverride @override, IDictionary serializedAdditionalRawData, string connectionName) : base(type, options, @override, serializedAdditionalRawData) + { + ConnectionName = connectionName; + } + + /// Initializes a new instance of for deserialization. + internal BingGroundingToolDefinition() + { + } + + /// The name of the Bing grounding connection. + public string ConnectionName { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/BlobReferenceForConsumption.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/BlobReferenceForConsumption.Serialization.cs new file mode 100644 index 000000000000..eedd81b445eb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/BlobReferenceForConsumption.Serialization.cs @@ -0,0 +1,158 @@ +// 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.Projects.OneDP +{ + public partial class BlobReferenceForConsumption : 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(BlobReferenceForConsumption)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("blobUri"u8); + writer.WriteStringValue(BlobUri); + writer.WritePropertyName("storageAccountArmId"u8); + writer.WriteStringValue(StorageAccountArmId); + writer.WritePropertyName("credential"u8); + writer.WriteObjectValue(Credential, 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 + } + } + } + + BlobReferenceForConsumption 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(BlobReferenceForConsumption)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBlobReferenceForConsumption(document.RootElement, options); + } + + internal static BlobReferenceForConsumption DeserializeBlobReferenceForConsumption(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string blobUri = default; + string storageAccountArmId = default; + SasCredential credential = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("blobUri"u8)) + { + blobUri = property.Value.GetString(); + continue; + } + if (property.NameEquals("storageAccountArmId"u8)) + { + storageAccountArmId = property.Value.GetString(); + continue; + } + if (property.NameEquals("credential"u8)) + { + credential = SasCredential.DeserializeSasCredential(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BlobReferenceForConsumption(blobUri, storageAccountArmId, credential, 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(BlobReferenceForConsumption)} does not support writing '{options.Format}' format."); + } + } + + BlobReferenceForConsumption 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 DeserializeBlobReferenceForConsumption(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BlobReferenceForConsumption)} 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 BlobReferenceForConsumption FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBlobReferenceForConsumption(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/ai/Azure.AI.Projects.OneDP/src/Generated/BlobReferenceForConsumption.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/BlobReferenceForConsumption.cs new file mode 100644 index 000000000000..92c798d2b25a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/BlobReferenceForConsumption.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Represents a reference to a blob for consumption. + public partial class BlobReferenceForConsumption + { + /// + /// 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 . + /// Blob URI path for client to upload data. Example: https://blob.windows.core.net/Container/Path. + /// ARM ID of the storage account to use. + /// Credential info to access the storage account. + /// , or is null. + internal BlobReferenceForConsumption(string blobUri, string storageAccountArmId, SasCredential credential) + { + Argument.AssertNotNull(blobUri, nameof(blobUri)); + Argument.AssertNotNull(storageAccountArmId, nameof(storageAccountArmId)); + Argument.AssertNotNull(credential, nameof(credential)); + + BlobUri = blobUri; + StorageAccountArmId = storageAccountArmId; + Credential = credential; + } + + /// Initializes a new instance of . + /// Blob URI path for client to upload data. Example: https://blob.windows.core.net/Container/Path. + /// ARM ID of the storage account to use. + /// Credential info to access the storage account. + /// Keeps track of any properties unknown to the library. + internal BlobReferenceForConsumption(string blobUri, string storageAccountArmId, SasCredential credential, IDictionary serializedAdditionalRawData) + { + BlobUri = blobUri; + StorageAccountArmId = storageAccountArmId; + Credential = credential; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BlobReferenceForConsumption() + { + } + + /// Blob URI path for client to upload data. Example: https://blob.windows.core.net/Container/Path. + public string BlobUri { get; } + /// ARM ID of the storage account to use. + public string StorageAccountArmId { get; } + /// Credential info to access the storage account. + public SasCredential Credential { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ChatMessage.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ChatMessage.Serialization.cs new file mode 100644 index 000000000000..3e777c072cca --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ChatMessage.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.Text.Json; +using Azure.Core; + +namespace Azure.AI.Projects.OneDP +{ + [PersistableModelProxy(typeof(UnknownChatMessage))] + public partial class ChatMessage : 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(ChatMessage)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(UserId)) + { + writer.WritePropertyName("userId"u8); + writer.WriteStringValue(UserId); + } + if (Optional.IsDefined(AgentId)) + { + writer.WritePropertyName("agentId"u8); + writer.WriteStringValue(AgentId); + } + if (options.Format != "W") + { + writer.WritePropertyName("messageId"u8); + writer.WriteStringValue(MessageId); + } + if (Optional.IsDefined(AgentRunId)) + { + writer.WritePropertyName("agentRunId"u8); + writer.WriteStringValue(AgentRunId); + } + if (options.Format != "W") + { + writer.WritePropertyName("conversationId"u8); + writer.WriteStringValue(ConversationId); + } + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToString()); + writer.WritePropertyName("content"u8); + writer.WriteStartArray(); + foreach (var item in Content) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(AuthorName)) + { + writer.WritePropertyName("authorName"u8); + writer.WriteStringValue(AuthorName); + } + if (Optional.IsDefined(CreatedAt)) + { + writer.WritePropertyName("createdAt"u8); + writer.WriteNumberValue(CreatedAt.Value); + } + if (Optional.IsDefined(CompletedAt)) + { + writer.WritePropertyName("completedAt"u8); + writer.WriteNumberValue(CompletedAt.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 + } + } + } + + ChatMessage 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(ChatMessage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatMessage(document.RootElement, options); + } + + internal static ChatMessage DeserializeChatMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("role", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "agent": return AgentMessage.DeserializeAgentMessage(element, options); + case "developer": return DeveloperMessage.DeserializeDeveloperMessage(element, options); + case "system": return SystemMessage.DeserializeSystemMessage(element, options); + case "tool": return ToolMessage.DeserializeToolMessage(element, options); + case "user": return UserMessage.DeserializeUserMessage(element, options); + } + } + return UnknownChatMessage.DeserializeUnknownChatMessage(element, options); + } + + 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(ChatMessage)} does not support writing '{options.Format}' format."); + } + } + + ChatMessage 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 DeserializeChatMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatMessage)} 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 ChatMessage FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeChatMessage(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/ai/Azure.AI.Projects.OneDP/src/Generated/ChatMessage.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ChatMessage.cs new file mode 100644 index 000000000000..1cecc9528f46 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ChatMessage.cs @@ -0,0 +1,128 @@ +// 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.Projects.OneDP +{ + /// + /// A base model for representing a chat message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + public abstract partial class ChatMessage + { + /// + /// 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 protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// is null. + protected ChatMessage(IEnumerable content) + { + Argument.AssertNotNull(content, nameof(content)); + + Content = content.ToList(); + } + + /// Initializes a new instance of . + /// The ID of the user who created the message (if applicable). + /// The ID of the agent who created the message (if applicable). + /// A unique identifier for this message. + /// A unique run ID, if this message was generated by a run process. + /// The conversation to which this message belongs. + /// The role of this message's author. + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// An optional display name for the author. + /// The timestamp (in Unix time) when this message was created. + /// The timestamp (in Unix time) when this message was completed, if applicable. + /// Keeps track of any properties unknown to the library. + internal ChatMessage(string userId, string agentId, string messageId, string agentRunId, string conversationId, AuthorRole role, IList content, string authorName, long? createdAt, long? completedAt, IDictionary serializedAdditionalRawData) + { + UserId = userId; + AgentId = agentId; + MessageId = messageId; + AgentRunId = agentRunId; + ConversationId = conversationId; + Role = role; + Content = content; + AuthorName = authorName; + CreatedAt = createdAt; + CompletedAt = completedAt; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ChatMessage() + { + } + + /// The ID of the user who created the message (if applicable). + public string UserId { get; set; } + /// The ID of the agent who created the message (if applicable). + public string AgentId { get; set; } + /// A unique identifier for this message. + public string MessageId { get; } + /// A unique run ID, if this message was generated by a run process. + public string AgentRunId { get; set; } + /// The conversation to which this message belongs. + public string ConversationId { get; } + /// The role of this message's author. + internal AuthorRole Role { get; set; } + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + public IList Content { get; } + /// An optional display name for the author. + public string AuthorName { get; set; } + /// The timestamp (in Unix time) when this message was created. + public long? CreatedAt { get; set; } + /// The timestamp (in Unix time) when this message was completed, if applicable. + public long? CompletedAt { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CodeInterpreterToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CodeInterpreterToolDefinition.Serialization.cs new file mode 100644 index 000000000000..35b083723014 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CodeInterpreterToolDefinition.Serialization.cs @@ -0,0 +1,164 @@ +// 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.Projects.OneDP +{ + public partial class CodeInterpreterToolDefinition : 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 override 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(CodeInterpreterToolDefinition)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("fileIds"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + + CodeInterpreterToolDefinition 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(CodeInterpreterToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCodeInterpreterToolDefinition(document.RootElement, options); + } + + internal static CodeInterpreterToolDefinition DeserializeCodeInterpreterToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList fileIds = default; + string type = default; + AgentToolOptions options0 = default; + AgentToolDefinitionOverride @override = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("fileIds"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + fileIds = array; + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("options"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + options0 = AgentToolOptions.DeserializeAgentToolOptions(property.Value, options); + continue; + } + if (property.NameEquals("override"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + @override = AgentToolDefinitionOverride.DeserializeAgentToolDefinitionOverride(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CodeInterpreterToolDefinition(type, options0, @override, serializedAdditionalRawData, fileIds); + } + + 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(CodeInterpreterToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + CodeInterpreterToolDefinition 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 DeserializeCodeInterpreterToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CodeInterpreterToolDefinition)} 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 new CodeInterpreterToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCodeInterpreterToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CodeInterpreterToolDefinition.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CodeInterpreterToolDefinition.cs new file mode 100644 index 000000000000..ede905b5970b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CodeInterpreterToolDefinition.cs @@ -0,0 +1,47 @@ +// 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.Projects.OneDP +{ + /// A tool definition for the OpenAI Code Interpreter. + public partial class CodeInterpreterToolDefinition : AgentToolDefinition + { + /// Initializes a new instance of . + /// A list of file IDs this code interpreter requires. + /// is null. + public CodeInterpreterToolDefinition(IEnumerable fileIds) + { + Argument.AssertNotNull(fileIds, nameof(fileIds)); + + Type = "OpenAI.CodeInterpreter"; + FileIds = fileIds.ToList(); + } + + /// Initializes a new instance of . + /// Discriminates the various child 'tool definition' types. + /// Additional options that specify the behavior of this tool (also polymorphic). + /// A set of overrides for the tool's name, description, or parameters. + /// Keeps track of any properties unknown to the library. + /// A list of file IDs this code interpreter requires. + internal CodeInterpreterToolDefinition(string type, AgentToolOptions options, AgentToolDefinitionOverride @override, IDictionary serializedAdditionalRawData, IList fileIds) : base(type, options, @override, serializedAdditionalRawData) + { + FileIds = fileIds; + } + + /// Initializes a new instance of for deserialization. + internal CodeInterpreterToolDefinition() + { + } + + /// A list of file IDs this code interpreter requires. + public IList FileIds { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CompletionUsage.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CompletionUsage.Serialization.cs new file mode 100644 index 000000000000..593e9cecba25 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CompletionUsage.Serialization.cs @@ -0,0 +1,194 @@ +// 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.Projects.OneDP +{ + public partial class CompletionUsage : 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(CompletionUsage)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("outputTokens"u8); + writer.WriteNumberValue(OutputTokens); + writer.WritePropertyName("inputTokens"u8); + writer.WriteNumberValue(InputTokens); + writer.WritePropertyName("totalTokens"u8); + writer.WriteNumberValue(TotalTokens); + if (Optional.IsDefined(InputTokenDetails)) + { + writer.WritePropertyName("inputTokenDetails"u8); + writer.WriteObjectValue(InputTokenDetails, options); + } + if (Optional.IsDefined(OutputTokenDetails)) + { + writer.WritePropertyName("outputTokenDetails"u8); + writer.WriteObjectValue(OutputTokenDetails, 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 + } + } + } + + CompletionUsage 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(CompletionUsage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCompletionUsage(document.RootElement, options); + } + + internal static CompletionUsage DeserializeCompletionUsage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + long outputTokens = default; + long inputTokens = default; + long totalTokens = default; + CompletionUsageInputTokenDetails inputTokenDetails = default; + CompletionUsageOutputTokenDetails outputTokenDetails = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("outputTokens"u8)) + { + outputTokens = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("inputTokens"u8)) + { + inputTokens = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("totalTokens"u8)) + { + totalTokens = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("inputTokenDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + inputTokenDetails = CompletionUsageInputTokenDetails.DeserializeCompletionUsageInputTokenDetails(property.Value, options); + continue; + } + if (property.NameEquals("outputTokenDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + outputTokenDetails = CompletionUsageOutputTokenDetails.DeserializeCompletionUsageOutputTokenDetails(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CompletionUsage( + outputTokens, + inputTokens, + totalTokens, + inputTokenDetails, + outputTokenDetails, + 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(CompletionUsage)} does not support writing '{options.Format}' format."); + } + } + + CompletionUsage 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 DeserializeCompletionUsage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CompletionUsage)} 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 CompletionUsage FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCompletionUsage(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/ai/Azure.AI.Projects.OneDP/src/Generated/CompletionUsage.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CompletionUsage.cs new file mode 100644 index 000000000000..9cf7602eece4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CompletionUsage.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Detailed token usage data for a run request. + public partial class CompletionUsage + { + /// + /// 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 . + /// Number of run (completion) tokens used over the course of the run. + /// Number of prompt tokens used over the course of the run step. + /// Total number of tokens used (prompt + run). + internal CompletionUsage(long outputTokens, long inputTokens, long totalTokens) + { + OutputTokens = outputTokens; + InputTokens = inputTokens; + TotalTokens = totalTokens; + } + + /// Initializes a new instance of . + /// Number of run (completion) tokens used over the course of the run. + /// Number of prompt tokens used over the course of the run step. + /// Total number of tokens used (prompt + run). + /// Details of the prompt tokens. + /// Breakdown of tokens used in a run. + /// Keeps track of any properties unknown to the library. + internal CompletionUsage(long outputTokens, long inputTokens, long totalTokens, CompletionUsageInputTokenDetails inputTokenDetails, CompletionUsageOutputTokenDetails outputTokenDetails, IDictionary serializedAdditionalRawData) + { + OutputTokens = outputTokens; + InputTokens = inputTokens; + TotalTokens = totalTokens; + InputTokenDetails = inputTokenDetails; + OutputTokenDetails = outputTokenDetails; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CompletionUsage() + { + } + + /// Number of run (completion) tokens used over the course of the run. + public long OutputTokens { get; } + /// Number of prompt tokens used over the course of the run step. + public long InputTokens { get; } + /// Total number of tokens used (prompt + run). + public long TotalTokens { get; } + /// Details of the prompt tokens. + public CompletionUsageInputTokenDetails InputTokenDetails { get; } + /// Breakdown of tokens used in a run. + public CompletionUsageOutputTokenDetails OutputTokenDetails { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CompletionUsageInputTokenDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CompletionUsageInputTokenDetails.Serialization.cs new file mode 100644 index 000000000000..42915b7c4f30 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CompletionUsageInputTokenDetails.Serialization.cs @@ -0,0 +1,149 @@ +// 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.Projects.OneDP +{ + public partial class CompletionUsageInputTokenDetails : 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(CompletionUsageInputTokenDetails)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(CachedTokens)) + { + writer.WritePropertyName("cachedTokens"u8); + writer.WriteNumberValue(CachedTokens.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 + } + } + } + + CompletionUsageInputTokenDetails 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(CompletionUsageInputTokenDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCompletionUsageInputTokenDetails(document.RootElement, options); + } + + internal static CompletionUsageInputTokenDetails DeserializeCompletionUsageInputTokenDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? cachedTokens = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("cachedTokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + cachedTokens = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CompletionUsageInputTokenDetails(cachedTokens, 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(CompletionUsageInputTokenDetails)} does not support writing '{options.Format}' format."); + } + } + + CompletionUsageInputTokenDetails 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 DeserializeCompletionUsageInputTokenDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CompletionUsageInputTokenDetails)} 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 CompletionUsageInputTokenDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCompletionUsageInputTokenDetails(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/ai/Azure.AI.Projects.OneDP/src/Generated/CompletionUsageInputTokenDetails.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CompletionUsageInputTokenDetails.cs new file mode 100644 index 000000000000..326c006afece --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CompletionUsageInputTokenDetails.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.Projects.OneDP +{ + /// The CompletionUsageInputTokenDetails. + public partial class CompletionUsageInputTokenDetails + { + /// + /// 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 CompletionUsageInputTokenDetails() + { + } + + /// Initializes a new instance of . + /// The number of cached prompt tokens. + /// Keeps track of any properties unknown to the library. + internal CompletionUsageInputTokenDetails(int? cachedTokens, IDictionary serializedAdditionalRawData) + { + CachedTokens = cachedTokens; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The number of cached prompt tokens. + public int? CachedTokens { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CompletionUsageOutputTokenDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CompletionUsageOutputTokenDetails.Serialization.cs new file mode 100644 index 000000000000..9f033648dd70 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CompletionUsageOutputTokenDetails.Serialization.cs @@ -0,0 +1,149 @@ +// 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.Projects.OneDP +{ + public partial class CompletionUsageOutputTokenDetails : 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(CompletionUsageOutputTokenDetails)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ReasoningTokens)) + { + writer.WritePropertyName("reasoningTokens"u8); + writer.WriteNumberValue(ReasoningTokens.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 + } + } + } + + CompletionUsageOutputTokenDetails 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(CompletionUsageOutputTokenDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCompletionUsageOutputTokenDetails(document.RootElement, options); + } + + internal static CompletionUsageOutputTokenDetails DeserializeCompletionUsageOutputTokenDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? reasoningTokens = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("reasoningTokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + reasoningTokens = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CompletionUsageOutputTokenDetails(reasoningTokens, 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(CompletionUsageOutputTokenDetails)} does not support writing '{options.Format}' format."); + } + } + + CompletionUsageOutputTokenDetails 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 DeserializeCompletionUsageOutputTokenDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CompletionUsageOutputTokenDetails)} 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 CompletionUsageOutputTokenDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCompletionUsageOutputTokenDetails(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/ai/Azure.AI.Projects.OneDP/src/Generated/CompletionUsageOutputTokenDetails.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CompletionUsageOutputTokenDetails.cs new file mode 100644 index 000000000000..109092a2b5a7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CompletionUsageOutputTokenDetails.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.Projects.OneDP +{ + /// The CompletionUsageOutputTokenDetails. + public partial class CompletionUsageOutputTokenDetails + { + /// + /// 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 CompletionUsageOutputTokenDetails() + { + } + + /// Initializes a new instance of . + /// Tokens generated by the model for reasoning. + /// Keeps track of any properties unknown to the library. + internal CompletionUsageOutputTokenDetails(int? reasoningTokens, IDictionary serializedAdditionalRawData) + { + ReasoningTokens = reasoningTokens; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Tokens generated by the model for reasoning. + public int? ReasoningTokens { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Connection.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Connection.Serialization.cs new file mode 100644 index 000000000000..7e61629c8543 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Connection.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.Projects.OneDP +{ + public partial class Connection : 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(Connection)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + } + if (options.Format != "W") + { + writer.WritePropertyName("target"u8); + writer.WriteStringValue(Target); + } + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + 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 + } + } + } + + Connection 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(Connection)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConnection(document.RootElement, options); + } + + internal static Connection DeserializeConnection(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + ConnectionType type = default; + string target = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ConnectionType(property.Value.GetString()); + continue; + } + if (property.NameEquals("target"u8)) + { + target = property.Value.GetString(); + continue; + } + if (property.NameEquals("metadata"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Connection(name, type, target, metadata, 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(Connection)} does not support writing '{options.Format}' format."); + } + } + + Connection 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 DeserializeConnection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Connection)} 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 Connection FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeConnection(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/ai/Azure.AI.Projects.OneDP/src/Generated/Connection.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Connection.cs new file mode 100644 index 000000000000..ce7b8c8cdd38 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Connection.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Response from the listSecrets operation. + public partial class Connection + { + /// + /// 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 of the connection. + /// is null. + internal Connection(IReadOnlyDictionary metadata) + { + Argument.AssertNotNull(metadata, nameof(metadata)); + + Metadata = metadata; + } + + /// Initializes a new instance of . + /// The name of the resource. + /// Category of the connection. + /// The connection URL to be used for this service. + /// Metadata of the connection. + /// Keeps track of any properties unknown to the library. + internal Connection(string name, ConnectionType type, string target, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Name = name; + Type = type; + Target = target; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Connection() + { + } + + /// The name of the resource. + public string Name { get; } + /// Category of the connection. + public ConnectionType Type { get; } + /// The connection URL to be used for this service. + public string Target { get; } + /// Metadata of the connection. + public IReadOnlyDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ConnectionType.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ConnectionType.cs new file mode 100644 index 000000000000..93e964488b19 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ConnectionType.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.Projects.OneDP +{ + /// The Type (or category) of the connection. + public readonly partial struct ConnectionType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ConnectionType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AzureOpenAIValue = "AzureOpenAI"; + private const string AzureBlobStorageValue = "AzureBlob"; + private const string AzureAISearchValue = "CognitiveSearch"; + private const string CosmosDBValue = "CosmosDB"; + private const string APIKeyValue = "ApiKey"; + private const string ApplicationInsightsValue = "AppInsights"; + private const string CustomValue = "CustomKeys"; + + /// Azure OpenAI Service. + public static ConnectionType AzureOpenAI { get; } = new ConnectionType(AzureOpenAIValue); + /// Azure Blob Storage. + public static ConnectionType AzureBlobStorage { get; } = new ConnectionType(AzureBlobStorageValue); + /// Azure AI Search. + public static ConnectionType AzureAISearch { get; } = new ConnectionType(AzureAISearchValue); + /// CosmosDB. + public static ConnectionType CosmosDB { get; } = new ConnectionType(CosmosDBValue); + /// Generic connection that uses API Key authentication. + public static ConnectionType APIKey { get; } = new ConnectionType(APIKeyValue); + /// Application Insights. + public static ConnectionType ApplicationInsights { get; } = new ConnectionType(ApplicationInsightsValue); + /// Custom Keys. + public static ConnectionType Custom { get; } = new ConnectionType(CustomValue); + /// Determines if two values are the same. + public static bool operator ==(ConnectionType left, ConnectionType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ConnectionType left, ConnectionType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ConnectionType(string value) => new ConnectionType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ConnectionType other && Equals(other); + /// + public bool Equals(ConnectionType 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/ai/Azure.AI.Projects.OneDP/src/Generated/Connections.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Connections.cs new file mode 100644 index 000000000000..efbffb40d1f8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Connections.cs @@ -0,0 +1,330 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Projects.OneDP +{ + // Data plane generated sub-client. + /// The Connections sub-client. + public partial class Connections + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + 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 Connections for mocking. + protected Connections() + { + } + + /// Initializes a new instance of Connections. + /// 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. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// The API version to use for this operation. + internal Connections(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Get a connection by name. + /// The name of the resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetConnectionAsync(string connectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(connectionName, nameof(connectionName)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetConnectionAsync(connectionName, context).ConfigureAwait(false); + return Response.FromValue(Connection.FromResponse(response), response); + } + + /// Get a connection by name. + /// The name of the resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetConnection(string connectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(connectionName, nameof(connectionName)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetConnection(connectionName, context); + return Response.FromValue(Connection.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get a connection by name. + /// + /// + /// + /// 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 resource. + /// 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 GetConnectionAsync(string connectionName, RequestContext context) + { + Argument.AssertNotNullOrEmpty(connectionName, nameof(connectionName)); + + using var scope = ClientDiagnostics.CreateScope("Connections.GetConnection"); + scope.Start(); + try + { + using HttpMessage message = CreateGetConnectionRequest(connectionName, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get a connection by name. + /// + /// + /// + /// 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 resource. + /// 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 GetConnection(string connectionName, RequestContext context) + { + Argument.AssertNotNullOrEmpty(connectionName, nameof(connectionName)); + + using var scope = ClientDiagnostics.CreateScope("Connections.GetConnection"); + scope.Start(); + try + { + using HttpMessage message = CreateGetConnectionRequest(connectionName, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List all connections in the project. + /// Specific type of connection to return in list. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// + public virtual AsyncPageable GetConnectionsAsync(ConnectionType? connectionType = null, 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) => CreateGetConnectionsRequest(connectionType?.ToString(), maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetConnectionsNextPageRequest(nextLink, connectionType?.ToString(), maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Connection.DeserializeConnection(e), ClientDiagnostics, _pipeline, "Connections.GetConnections", "value", "nextLink", maxpagesize, context); + } + + /// List all connections in the project. + /// Specific type of connection to return in list. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// + public virtual Pageable GetConnections(ConnectionType? connectionType = null, 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) => CreateGetConnectionsRequest(connectionType?.ToString(), maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetConnectionsNextPageRequest(nextLink, connectionType?.ToString(), maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Connection.DeserializeConnection(e), ClientDiagnostics, _pipeline, "Connections.GetConnections", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] List all connections in the project + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specific type of connection to return in list. Allowed values: "AzureOpenAI" | "AzureBlob" | "CognitiveSearch" | "CosmosDB" | "ApiKey" | "AppInsights" | "CustomKeys". + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// 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 GetConnectionsAsync(string connectionType, int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetConnectionsRequest(connectionType, maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetConnectionsNextPageRequest(nextLink, connectionType, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Connections.GetConnections", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] List all connections in the project + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specific type of connection to return in list. Allowed values: "AzureOpenAI" | "AzureBlob" | "CognitiveSearch" | "CosmosDB" | "ApiKey" | "AppInsights" | "CustomKeys". + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// 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 GetConnections(string connectionType, int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetConnectionsRequest(connectionType, maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetConnectionsNextPageRequest(nextLink, connectionType, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Connections.GetConnections", "value", "nextLink", maxpagesize, context); + } + + internal HttpMessage CreateGetConnectionRequest(string connectionName, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/connections/", false); + uri.AppendPath(connectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetConnectionsRequest(string connectionType, int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/connections", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (connectionType != null) + { + uri.AppendQuery("connectionType", connectionType, 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 CreateGetConnectionsNextPageRequest(string nextLink, string connectionType, int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + 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/ai/Azure.AI.Projects.OneDP/src/Generated/ContentFilterContent.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ContentFilterContent.Serialization.cs new file mode 100644 index 000000000000..ec6457d9bd32 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ContentFilterContent.Serialization.cs @@ -0,0 +1,142 @@ +// 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.Projects.OneDP +{ + public partial class ContentFilterContent : 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 override 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(ContentFilterContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("contentFilter"u8); + writer.WriteStringValue(ContentFilter); + writer.WritePropertyName("detected"u8); + writer.WriteBooleanValue(Detected); + } + + ContentFilterContent 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(ContentFilterContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeContentFilterContent(document.RootElement, options); + } + + internal static ContentFilterContent DeserializeContentFilterContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string contentFilter = default; + bool detected = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("contentFilter"u8)) + { + contentFilter = property.Value.GetString(); + continue; + } + if (property.NameEquals("detected"u8)) + { + detected = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ContentFilterContent(type, serializedAdditionalRawData, contentFilter, detected); + } + + 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(ContentFilterContent)} does not support writing '{options.Format}' format."); + } + } + + ContentFilterContent 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 DeserializeContentFilterContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ContentFilterContent)} 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 new ContentFilterContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeContentFilterContent(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ContentFilterContent.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ContentFilterContent.cs new file mode 100644 index 000000000000..fa2a3bbb74b6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ContentFilterContent.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// A structured chat content item containing a content filter. + public partial class ContentFilterContent : AIContent + { + /// Initializes a new instance of . + /// Content filter data. + /// Whether content was flagged/detected. + /// is null. + public ContentFilterContent(string contentFilter, bool detected) + { + Argument.AssertNotNull(contentFilter, nameof(contentFilter)); + + Type = "contentFilter"; + ContentFilter = contentFilter; + Detected = detected; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// Content filter data. + /// Whether content was flagged/detected. + internal ContentFilterContent(string type, IDictionary serializedAdditionalRawData, string contentFilter, bool detected) : base(type, serializedAdditionalRawData) + { + ContentFilter = contentFilter; + Detected = detected; + } + + /// Initializes a new instance of for deserialization. + internal ContentFilterContent() + { + } + + /// Content filter data. + public string ContentFilter { get; set; } + /// Whether content was flagged/detected. + public bool Detected { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Conversation.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Conversation.Serialization.cs new file mode 100644 index 000000000000..1d3cd6fbcecd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Conversation.Serialization.cs @@ -0,0 +1,163 @@ +// 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.Projects.OneDP +{ + public partial class Conversation : 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(Conversation)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("conversationId"u8); + writer.WriteStringValue(ConversationId); + } + writer.WritePropertyName("messages"u8); + writer.WriteStartArray(); + foreach (var item in Messages) + { + 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 + } + } + } + + Conversation 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(Conversation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConversation(document.RootElement, options); + } + + internal static Conversation DeserializeConversation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string conversationId = default; + IList messages = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("conversationId"u8)) + { + conversationId = property.Value.GetString(); + continue; + } + if (property.NameEquals("messages"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ChatMessage.DeserializeChatMessage(item, options)); + } + messages = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Conversation(conversationId, messages, 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(Conversation)} does not support writing '{options.Format}' format."); + } + } + + Conversation 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 DeserializeConversation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Conversation)} 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 Conversation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeConversation(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/ai/Azure.AI.Projects.OneDP/src/Generated/Conversation.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Conversation.cs new file mode 100644 index 000000000000..c718fe6530ef --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Conversation.cs @@ -0,0 +1,92 @@ +// 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.Projects.OneDP +{ + /// Represents a chat conversation, which can contain multiple messages. + public partial class Conversation + { + /// + /// 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 . + /// + /// A list of messages in this conversation. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// is null. + public Conversation(IEnumerable messages) + { + Argument.AssertNotNull(messages, nameof(messages)); + + Messages = messages.ToList(); + } + + /// Initializes a new instance of . + /// A unique identifier for this conversation. + /// + /// A list of messages in this conversation. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// Keeps track of any properties unknown to the library. + internal Conversation(string conversationId, IList messages, IDictionary serializedAdditionalRawData) + { + ConversationId = conversationId; + Messages = messages; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Conversation() + { + } + + /// A unique identifier for this conversation. + public string ConversationId { get; } + /// + /// A list of messages in this conversation. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + public IList Messages { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Conversations.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Conversations.cs new file mode 100644 index 000000000000..c4a90a320ebb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Conversations.cs @@ -0,0 +1,673 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Projects.OneDP +{ + // Data plane generated sub-client. + /// + /// CONVERSATIONS + /// + /// Interface is rooted at /conversations. + /// + public partial class Conversations + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + 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 Conversations for mocking. + protected Conversations() + { + } + + /// Initializes a new instance of Conversations. + /// 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. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// The API version to use for this operation. + internal Conversations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Creates a new Conversation and returns it. + /// A list of messages in this conversation. + /// The cancellation token to use. + /// is null. + /// + public virtual async Task> CreateConversationAsync(IEnumerable messages, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(messages, nameof(messages)); + + CreateConversationRequest createConversationRequest = new CreateConversationRequest(messages.ToList(), null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateConversationAsync(createConversationRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(Conversation.FromResponse(response), response); + } + + /// Creates a new Conversation and returns it. + /// A list of messages in this conversation. + /// The cancellation token to use. + /// is null. + /// + public virtual Response CreateConversation(IEnumerable messages, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(messages, nameof(messages)); + + CreateConversationRequest createConversationRequest = new CreateConversationRequest(messages.ToList(), null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CreateConversation(createConversationRequest.ToRequestContent(), context); + return Response.FromValue(Conversation.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates a new Conversation and returns it. + /// + /// + /// + /// 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 CreateConversationAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Conversations.CreateConversation"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateConversationRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates a new Conversation and returns it. + /// + /// + /// + /// 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 CreateConversation(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Conversations.CreateConversation"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateConversationRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieves an existing conversation by its ID. + /// The identifier of the Conversation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetConversationAsync(string conversationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetConversationAsync(conversationId, context).ConfigureAwait(false); + return Response.FromValue(Conversation.FromResponse(response), response); + } + + /// Retrieves an existing conversation by its ID. + /// The identifier of the Conversation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetConversation(string conversationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetConversation(conversationId, context); + return Response.FromValue(Conversation.FromResponse(response), response); + } + + /// + /// [Protocol Method] Retrieves an existing conversation by its ID. + /// + /// + /// + /// 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 identifier of the Conversation. + /// 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 GetConversationAsync(string conversationId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + + using var scope = ClientDiagnostics.CreateScope("Conversations.GetConversation"); + scope.Start(); + try + { + using HttpMessage message = CreateGetConversationRequest(conversationId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Retrieves an existing conversation by its ID. + /// + /// + /// + /// 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 identifier of the Conversation. + /// 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 GetConversation(string conversationId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + + using var scope = ClientDiagnostics.CreateScope("Conversations.GetConversation"); + scope.Start(); + try + { + using HttpMessage message = CreateGetConversationRequest(conversationId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Updates or replaces a conversation by its ID, returning the updated Conversation. + /// The identifier of the Conversation to update. + /// The updated Conversation resource data. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> UpdateConversationAsync(string conversationId, Conversation body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await UpdateConversationAsync(conversationId, content, context).ConfigureAwait(false); + return Response.FromValue(Conversation.FromResponse(response), response); + } + + /// Updates or replaces a conversation by its ID, returning the updated Conversation. + /// The identifier of the Conversation to update. + /// The updated Conversation resource data. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response UpdateConversation(string conversationId, Conversation body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = UpdateConversation(conversationId, content, context); + return Response.FromValue(Conversation.FromResponse(response), response); + } + + /// + /// [Protocol Method] Updates or replaces a conversation by its ID, returning the updated Conversation. + /// + /// + /// + /// 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 identifier of the Conversation to update. + /// 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 UpdateConversationAsync(string conversationId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Conversations.UpdateConversation"); + scope.Start(); + try + { + using HttpMessage message = CreateUpdateConversationRequest(conversationId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Updates or replaces a conversation by its ID, returning the updated Conversation. + /// + /// + /// + /// 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 identifier of the Conversation to update. + /// 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 UpdateConversation(string conversationId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Conversations.UpdateConversation"); + scope.Start(); + try + { + using HttpMessage message = CreateUpdateConversationRequest(conversationId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Deletes a conversation, returning 204 on success. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the conversation to delete. + /// 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 DeleteConversationAsync(string conversationId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + + using var scope = ClientDiagnostics.CreateScope("Conversations.DeleteConversation"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteConversationRequest(conversationId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Deletes a conversation, returning 204 on success. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the conversation to delete. + /// 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 DeleteConversation(string conversationId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + + using var scope = ClientDiagnostics.CreateScope("Conversations.DeleteConversation"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteConversationRequest(conversationId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Lists all conversations, returning an array of Conversation items. + /// The cancellation token to use. + /// + public virtual async Task>> GetConversationsAsync(CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetConversationsAsync(context).ConfigureAwait(false); + IReadOnlyList value = default; + using var document = await JsonDocument.ParseAsync(response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + List array = new List(); + foreach (var item in document.RootElement.EnumerateArray()) + { + array.Add(Conversation.DeserializeConversation(item)); + } + value = array; + return Response.FromValue(value, response); + } + + /// Lists all conversations, returning an array of Conversation items. + /// The cancellation token to use. + /// + public virtual Response> GetConversations(CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetConversations(context); + IReadOnlyList value = default; + using var document = JsonDocument.Parse(response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + List array = new List(); + foreach (var item in document.RootElement.EnumerateArray()) + { + array.Add(Conversation.DeserializeConversation(item)); + } + value = array; + return Response.FromValue(value, response); + } + + /// + /// [Protocol Method] Lists all conversations, returning an array of Conversation items. + /// + /// + /// + /// 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 request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetConversationsAsync(RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("Conversations.GetConversations"); + scope.Start(); + try + { + using HttpMessage message = CreateGetConversationsRequest(context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Lists all conversations, returning an array of Conversation items. + /// + /// + /// + /// 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 request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetConversations(RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("Conversations.GetConversations"); + scope.Start(); + try + { + using HttpMessage message = CreateGetConversationsRequest(context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateCreateConversationRequest(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.AppendPath("/conversations", 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; + } + + internal HttpMessage CreateGetConversationRequest(string conversationId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/conversations/", false); + uri.AppendPath(conversationId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateUpdateConversationRequest(string conversationId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/conversations/", false); + uri.AppendPath(conversationId, 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 CreateDeleteConversationRequest(string conversationId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/conversations/", false); + uri.AppendPath(conversationId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetConversationsRequest(RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/conversations", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + 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 }); + private static ResponseClassifier _responseClassifier204; + private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CosmosDBIndex.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CosmosDBIndex.Serialization.cs new file mode 100644 index 000000000000..d1e12fc4bb57 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CosmosDBIndex.Serialization.cs @@ -0,0 +1,215 @@ +// 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.Projects.OneDP +{ + public partial class CosmosDBIndex : 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 override 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(CosmosDBIndex)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("connectionName"u8); + writer.WriteStringValue(ConnectionName); + writer.WritePropertyName("databaseName"u8); + writer.WriteStringValue(DatabaseName); + writer.WritePropertyName("containerName"u8); + writer.WriteStringValue(ContainerName); + writer.WritePropertyName("embeddingConfiguration"u8); + writer.WriteObjectValue(EmbeddingConfiguration, options); + } + + CosmosDBIndex 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(CosmosDBIndex)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCosmosDBIndex(document.RootElement, options); + } + + internal static CosmosDBIndex DeserializeCosmosDBIndex(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string connectionName = default; + string databaseName = default; + string containerName = default; + EmbeddingConfiguration embeddingConfiguration = default; + IndexType type = default; + string stage = default; + string id = default; + string name = default; + string version = default; + string description = default; + IDictionary tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("connectionName"u8)) + { + connectionName = property.Value.GetString(); + continue; + } + if (property.NameEquals("databaseName"u8)) + { + databaseName = property.Value.GetString(); + continue; + } + if (property.NameEquals("containerName"u8)) + { + containerName = property.Value.GetString(); + continue; + } + if (property.NameEquals("embeddingConfiguration"u8)) + { + embeddingConfiguration = EmbeddingConfiguration.DeserializeEmbeddingConfiguration(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new IndexType(property.Value.GetString()); + continue; + } + if (property.NameEquals("stage"u8)) + { + stage = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("version"u8)) + { + version = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"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()); + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CosmosDBIndex( + type, + stage, + id, + name, + version, + description, + tags ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData, + connectionName, + databaseName, + containerName, + embeddingConfiguration); + } + + 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(CosmosDBIndex)} does not support writing '{options.Format}' format."); + } + } + + CosmosDBIndex 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 DeserializeCosmosDBIndex(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CosmosDBIndex)} 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 new CosmosDBIndex FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCosmosDBIndex(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CosmosDBIndex.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CosmosDBIndex.cs new file mode 100644 index 000000000000..85649157ac70 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CosmosDBIndex.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.Projects.OneDP +{ + /// CosmosDB Vector Store Index Definition. + public partial class CosmosDBIndex : Index + { + /// Initializes a new instance of . + /// Name of connection to CosmosDB. + /// Name of the CosmosDB Database. + /// Name of CosmosDB Container. + /// Embedding model configuration. + /// , , or is null. + public CosmosDBIndex(string connectionName, string databaseName, string containerName, EmbeddingConfiguration embeddingConfiguration) + { + Argument.AssertNotNull(connectionName, nameof(connectionName)); + Argument.AssertNotNull(databaseName, nameof(databaseName)); + Argument.AssertNotNull(containerName, nameof(containerName)); + Argument.AssertNotNull(embeddingConfiguration, nameof(embeddingConfiguration)); + + Type = IndexType.CosmosDB; + ConnectionName = connectionName; + DatabaseName = databaseName; + ContainerName = containerName; + EmbeddingConfiguration = embeddingConfiguration; + } + + /// Initializes a new instance of . + /// Type of index. + /// Asset stage. + /// A unique identifier for the asset, assetId probably?. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Keeps track of any properties unknown to the library. + /// Name of connection to CosmosDB. + /// Name of the CosmosDB Database. + /// Name of CosmosDB Container. + /// Embedding model configuration. + internal CosmosDBIndex(IndexType type, string stage, string id, string name, string version, string description, IDictionary tags, IDictionary serializedAdditionalRawData, string connectionName, string databaseName, string containerName, EmbeddingConfiguration embeddingConfiguration) : base(type, stage, id, name, version, description, tags, serializedAdditionalRawData) + { + ConnectionName = connectionName; + DatabaseName = databaseName; + ContainerName = containerName; + EmbeddingConfiguration = embeddingConfiguration; + } + + /// Initializes a new instance of for deserialization. + internal CosmosDBIndex() + { + } + + /// Name of connection to CosmosDB. + public string ConnectionName { get; set; } + /// Name of the CosmosDB Database. + public string DatabaseName { get; set; } + /// Name of CosmosDB Container. + public string ContainerName { get; set; } + /// Embedding model configuration. + public EmbeddingConfiguration EmbeddingConfiguration { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CreateAgentRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CreateAgentRequest.Serialization.cs new file mode 100644 index 000000000000..4161474690c2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CreateAgentRequest.Serialization.cs @@ -0,0 +1,214 @@ +// 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.Projects.OneDP +{ + internal partial class CreateAgentRequest : 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(CreateAgentRequest)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + if (Optional.IsDefined(AgentModel)) + { + writer.WritePropertyName("agentModel"u8); + writer.WriteObjectValue(AgentModel, options); + } + if (Optional.IsDefined(Instructions)) + { + writer.WritePropertyName("instructions"u8); + writer.WriteStringValue(Instructions); + } + if (Optional.IsCollectionDefined(Tools)) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in Tools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ToolChoice)) + { + writer.WritePropertyName("toolChoice"u8); + writer.WriteObjectValue(ToolChoice, 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 + } + } + } + + CreateAgentRequest 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(CreateAgentRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateAgentRequest(document.RootElement, options); + } + + internal static CreateAgentRequest DeserializeCreateAgentRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string displayName = default; + AgentModel agentModel = default; + string instructions = default; + IReadOnlyList tools = default; + ToolChoiceBehavior toolChoice = 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("agentModel"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + agentModel = AgentModel.DeserializeAgentModel(property.Value, options); + continue; + } + if (property.NameEquals("instructions"u8)) + { + instructions = property.Value.GetString(); + continue; + } + if (property.NameEquals("tools"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AgentToolDefinition.DeserializeAgentToolDefinition(item, options)); + } + tools = array; + continue; + } + if (property.NameEquals("toolChoice"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + toolChoice = ToolChoiceBehavior.DeserializeToolChoiceBehavior(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CreateAgentRequest( + displayName, + agentModel, + instructions, + tools ?? new ChangeTrackingList(), + toolChoice, + 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(CreateAgentRequest)} does not support writing '{options.Format}' format."); + } + } + + CreateAgentRequest 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 DeserializeCreateAgentRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateAgentRequest)} 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 CreateAgentRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateAgentRequest(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/ai/Azure.AI.Projects.OneDP/src/Generated/CreateAgentRequest.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CreateAgentRequest.cs new file mode 100644 index 000000000000..a9a49ed7d3c3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CreateAgentRequest.cs @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// The CreateAgentRequest. + internal partial class CreateAgentRequest + { + /// + /// 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 display name of the agent; used for display purposes and sent to the LLM to identify the agent. + /// is null. + internal CreateAgentRequest(string displayName) + { + Argument.AssertNotNull(displayName, nameof(displayName)); + + DisplayName = displayName; + Tools = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The display name of the agent; used for display purposes and sent to the LLM to identify the agent. + /// + /// The model definition for this agent. This is optional (not needed) when doing a run using persistent agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// Instructions provided to guide how this agent operates. + /// + /// A list of tool definitions available to the agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// + /// How the agent should choose among provided tools. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + /// Keeps track of any properties unknown to the library. + internal CreateAgentRequest(string displayName, AgentModel agentModel, string instructions, IReadOnlyList tools, ToolChoiceBehavior toolChoice, IDictionary serializedAdditionalRawData) + { + DisplayName = displayName; + AgentModel = agentModel; + Instructions = instructions; + Tools = tools; + ToolChoice = toolChoice; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CreateAgentRequest() + { + } + + /// The display name of the agent; used for display purposes and sent to the LLM to identify the agent. + public string DisplayName { get; } + /// + /// The model definition for this agent. This is optional (not needed) when doing a run using persistent agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public AgentModel AgentModel { get; } + /// Instructions provided to guide how this agent operates. + public string Instructions { get; } + /// + /// A list of tool definitions available to the agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + public IReadOnlyList Tools { get; } + /// + /// How the agent should choose among provided tools. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public ToolChoiceBehavior ToolChoice { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CreateConversationRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CreateConversationRequest.Serialization.cs new file mode 100644 index 000000000000..1dc72888d2a5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CreateConversationRequest.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.Projects.OneDP +{ + internal partial class CreateConversationRequest : 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(CreateConversationRequest)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("messages"u8); + writer.WriteStartArray(); + foreach (var item in Messages) + { + 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 + } + } + } + + CreateConversationRequest 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(CreateConversationRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateConversationRequest(document.RootElement, options); + } + + internal static CreateConversationRequest DeserializeCreateConversationRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList messages = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("messages"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ChatMessage.DeserializeChatMessage(item, options)); + } + messages = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CreateConversationRequest(messages, 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(CreateConversationRequest)} does not support writing '{options.Format}' format."); + } + } + + CreateConversationRequest 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 DeserializeCreateConversationRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateConversationRequest)} 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 CreateConversationRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateConversationRequest(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/ai/Azure.AI.Projects.OneDP/src/Generated/CreateConversationRequest.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CreateConversationRequest.cs new file mode 100644 index 000000000000..7f453c23bac8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CreateConversationRequest.cs @@ -0,0 +1,88 @@ +// 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.Projects.OneDP +{ + /// The CreateConversationRequest. + internal partial class CreateConversationRequest + { + /// + /// 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 . + /// + /// A list of messages in this conversation. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// is null. + internal CreateConversationRequest(IEnumerable messages) + { + Argument.AssertNotNull(messages, nameof(messages)); + + Messages = messages.ToList(); + } + + /// Initializes a new instance of . + /// + /// A list of messages in this conversation. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// Keeps track of any properties unknown to the library. + internal CreateConversationRequest(IReadOnlyList messages, IDictionary serializedAdditionalRawData) + { + Messages = messages; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CreateConversationRequest() + { + } + + /// + /// A list of messages in this conversation. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + public IReadOnlyList Messages { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CredentialType.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CredentialType.cs new file mode 100644 index 000000000000..a845cb1880e1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/CredentialType.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects.OneDP +{ + /// The different Credential types. + internal readonly partial struct CredentialType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CredentialType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ApiKeyValue = "ApiKey"; + private const string AADValue = "AAD"; + private const string SASValue = "SAS"; + + /// ApiKey. + public static CredentialType ApiKey { get; } = new CredentialType(ApiKeyValue); + /// AAD. + public static CredentialType AAD { get; } = new CredentialType(AADValue); + /// SAS. + public static CredentialType SAS { get; } = new CredentialType(SASValue); + /// Determines if two values are the same. + public static bool operator ==(CredentialType left, CredentialType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CredentialType left, CredentialType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator CredentialType(string value) => new CredentialType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CredentialType other && Equals(other); + /// + public bool Equals(CredentialType 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/ai/Azure.AI.Projects.OneDP/src/Generated/DatasetType.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/DatasetType.cs new file mode 100644 index 000000000000..4be625d96a85 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/DatasetType.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.Projects.OneDP +{ + /// Enum to determine the type of data. + internal readonly partial struct DatasetType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DatasetType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UriFileValue = "uri_file"; + private const string UriFolderValue = "uri_folder"; + + /// URI file. + public static DatasetType UriFile { get; } = new DatasetType(UriFileValue); + /// URI folder. + public static DatasetType UriFolder { get; } = new DatasetType(UriFolderValue); + /// Determines if two values are the same. + public static bool operator ==(DatasetType left, DatasetType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DatasetType left, DatasetType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator DatasetType(string value) => new DatasetType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DatasetType other && Equals(other); + /// + public bool Equals(DatasetType 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/ai/Azure.AI.Projects.OneDP/src/Generated/DatasetVersion.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/DatasetVersion.Serialization.cs new file mode 100644 index 000000000000..16279d2cddce --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/DatasetVersion.Serialization.cs @@ -0,0 +1,177 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Projects.OneDP +{ + [PersistableModelProxy(typeof(UnknownDatasetVersion))] + public partial class DatasetVersion : 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(DatasetVersion)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("datasetUri"u8); + writer.WriteStringValue(DatasetUri); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && Optional.IsDefined(IsReference)) + { + writer.WritePropertyName("isReference"u8); + writer.WriteBooleanValue(IsReference.Value); + } + if (Optional.IsDefined(Stage)) + { + writer.WritePropertyName("stage"u8); + writer.WriteStringValue(Stage); + } + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + 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 + } + } + } + + DatasetVersion 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(DatasetVersion)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDatasetVersion(document.RootElement, options); + } + + internal static DatasetVersion DeserializeDatasetVersion(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "uri_file": return FileDatasetVersion.DeserializeFileDatasetVersion(element, options); + case "uri_folder": return FolderDatasetVersion.DeserializeFolderDatasetVersion(element, options); + } + } + return UnknownDatasetVersion.DeserializeUnknownDatasetVersion(element, options); + } + + 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(DatasetVersion)} does not support writing '{options.Format}' format."); + } + } + + DatasetVersion 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 DeserializeDatasetVersion(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DatasetVersion)} 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 DatasetVersion FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDatasetVersion(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/ai/Azure.AI.Projects.OneDP/src/Generated/DatasetVersion.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/DatasetVersion.cs new file mode 100644 index 000000000000..cefd86f144b6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/DatasetVersion.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.Projects.OneDP +{ + /// + /// DatasetVersion Definition + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public abstract partial class DatasetVersion + { + /// + /// 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 protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// [Required] Uri of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// is null. + protected DatasetVersion(string datasetUri) + { + Argument.AssertNotNull(datasetUri, nameof(datasetUri)); + + DatasetUri = datasetUri; + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// [Required] Uri of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// Dataset type. + /// Indicates if dataset is reference only or managed by dataset service. If true, the underlying data will be deleted when the dataset version is deleted. + /// Asset stage. + /// A unique identifier for the asset, assetId probably?. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Keeps track of any properties unknown to the library. + internal DatasetVersion(string datasetUri, DatasetType type, bool? isReference, string stage, string id, string name, string version, string description, IDictionary tags, IDictionary serializedAdditionalRawData) + { + DatasetUri = datasetUri; + Type = type; + IsReference = isReference; + Stage = stage; + Id = id; + Name = name; + Version = version; + Description = description; + Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DatasetVersion() + { + } + + /// [Required] Uri of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + public string DatasetUri { get; set; } + /// Dataset type. + internal DatasetType Type { get; set; } + /// Indicates if dataset is reference only or managed by dataset service. If true, the underlying data will be deleted when the dataset version is deleted. + public bool? IsReference { get; } + /// Asset stage. + public string Stage { get; set; } + /// A unique identifier for the asset, assetId probably?. + public string Id { get; } + /// The name of the resource. + public string Name { get; } + /// The version of the resource. + public string Version { get; } + /// The asset description text. + public string Description { get; set; } + /// Tag dictionary. Tags can be added, removed, and updated. + public IDictionary Tags { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Datasets.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Datasets.cs new file mode 100644 index 000000000000..471114a250bc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Datasets.cs @@ -0,0 +1,1170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Projects.OneDP +{ + // Data plane generated sub-client. + /// The Datasets sub-client. + public partial class Datasets + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + 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 Datasets for mocking. + protected Datasets() + { + } + + /// Initializes a new instance of Datasets. + /// 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. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// The API version to use for this operation. + internal Datasets(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Get the specific version of the DatasetVersion. + /// The name of the resource. + /// The specific version id of the DatasetVersion to retrieve. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetVersionAsync(string name, string version, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetVersionAsync(name, version, context).ConfigureAwait(false); + return Response.FromValue(DatasetVersion.FromResponse(response), response); + } + + /// Get the specific version of the DatasetVersion. + /// The name of the resource. + /// The specific version id of the DatasetVersion to retrieve. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response GetVersion(string name, string version, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetVersion(name, version, context); + return Response.FromValue(DatasetVersion.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get the specific version of the DatasetVersion + /// + /// + /// + /// 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 resource. + /// The specific version id of the DatasetVersion to retrieve. + /// 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 GetVersionAsync(string name, string version, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.GetVersion"); + scope.Start(); + try + { + using HttpMessage message = CreateGetVersionRequest(name, version, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get the specific version of the DatasetVersion + /// + /// + /// + /// 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 resource. + /// The specific version id of the DatasetVersion to retrieve. + /// 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 GetVersion(string name, string version, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.GetVersion"); + scope.Start(); + try + { + using HttpMessage message = CreateGetVersionRequest(name, version, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete the specific version of the DatasetVersion + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The name of the resource. + /// The version of the DatasetVersion to delete. + /// 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 DeleteVersionAsync(string name, string version, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.DeleteVersion"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteVersionRequest(name, version, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete the specific version of the DatasetVersion + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The name of the resource. + /// The version of the DatasetVersion to delete. + /// 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 DeleteVersion(string name, string version, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.DeleteVersion"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteVersionRequest(name, version, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Create a new DatasetVersion. The version id will be generated by the service. + /// The name of the resource. + /// The definition of the DatasetVersion to create. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> CreateAsync(string name, DatasetVersion body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateAsync(name, content, context).ConfigureAwait(false); + return Response.FromValue(DatasetVersion.FromResponse(response), response); + } + + /// Create a new DatasetVersion. The version id will be generated by the service. + /// The name of the resource. + /// The definition of the DatasetVersion to create. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response Create(string name, DatasetVersion body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = Create(name, content, context); + return Response.FromValue(DatasetVersion.FromResponse(response), response); + } + + /// + /// [Protocol Method] Create a new DatasetVersion. The version id will be generated by the service. + /// + /// + /// + /// 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 resource. + /// 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 CreateAsync(string name, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.Create"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateRequest(name, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create a new DatasetVersion. The version id will be generated by the service. + /// + /// + /// + /// 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 resource. + /// 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 Create(string name, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.Create"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateRequest(name, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Create a new or replace an existing DatasetVersion with the given version id. + /// The name of the resource. + /// The specific version id of the DatasetVersion to create or replace. + /// The definition of the DatasetVersion to create. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> CreateVersionAsync(string name, string version, DatasetVersion body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateVersionAsync(name, version, content, context).ConfigureAwait(false); + return Response.FromValue(DatasetVersion.FromResponse(response), response); + } + + /// Create a new or replace an existing DatasetVersion with the given version id. + /// The name of the resource. + /// The specific version id of the DatasetVersion to create or replace. + /// The definition of the DatasetVersion to create. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response CreateVersion(string name, string version, DatasetVersion body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CreateVersion(name, version, content, context); + return Response.FromValue(DatasetVersion.FromResponse(response), response); + } + + /// + /// [Protocol Method] Create a new or replace an existing DatasetVersion with the given version id + /// + /// + /// + /// 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 resource. + /// The specific version id of the DatasetVersion to create or replace. + /// 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. + /// 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 CreateVersionAsync(string name, string version, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.CreateVersion"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateVersionRequest(name, version, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create a new or replace an existing DatasetVersion with the given version id + /// + /// + /// + /// 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 resource. + /// The specific version id of the DatasetVersion to create or replace. + /// 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. + /// 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 CreateVersion(string name, string version, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.CreateVersion"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateVersionRequest(name, version, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Create or start a pending upload of a dataset for a specific version. + /// The name of the resource. + /// The specific version id of the DatasetVersion to operate on. + /// Parameters for the action. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> StartPendingUploadAsync(string name, string version, PendingUploadRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await StartPendingUploadAsync(name, version, content, context).ConfigureAwait(false); + return Response.FromValue(PendingUploadResponse.FromResponse(response), response); + } + + /// Create or start a pending upload of a dataset for a specific version. + /// The name of the resource. + /// The specific version id of the DatasetVersion to operate on. + /// Parameters for the action. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response StartPendingUpload(string name, string version, PendingUploadRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = StartPendingUpload(name, version, content, context); + return Response.FromValue(PendingUploadResponse.FromResponse(response), response); + } + + /// + /// [Protocol Method] Create or start a pending upload of a dataset for a specific version. + /// + /// + /// + /// 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 resource. + /// The specific version id of the DatasetVersion to operate on. + /// 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. + /// 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 StartPendingUploadAsync(string name, string version, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.StartPendingUpload"); + scope.Start(); + try + { + using HttpMessage message = CreateStartPendingUploadRequest(name, version, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create or start a pending upload of a dataset for a specific version. + /// + /// + /// + /// 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 resource. + /// The specific version id of the DatasetVersion to operate on. + /// 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. + /// 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 StartPendingUpload(string name, string version, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.StartPendingUpload"); + scope.Start(); + try + { + using HttpMessage message = CreateStartPendingUploadRequest(name, version, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Create or start a pending upload of a dataset. The dataset version will be generated by service. + /// The name of the resource. + /// TemporaryBlobReference is the only supported type. + /// If PendingUploadId is not provided, a random GUID will be used. + /// Name of Azure blob storage connection to use for generating temporary SAS token. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> StartPendingUploadAutoIncrementAsync(string name, PendingUploadType pendingUploadType, string pendingUploadId = null, string connectionName = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + StartPendingUploadAutoIncrementRequest startPendingUploadAutoIncrementRequest = new StartPendingUploadAutoIncrementRequest(pendingUploadId, connectionName, pendingUploadType, null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await StartPendingUploadAutoIncrementAsync(name, startPendingUploadAutoIncrementRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(PendingUploadResponse.FromResponse(response), response); + } + + /// Create or start a pending upload of a dataset. The dataset version will be generated by service. + /// The name of the resource. + /// TemporaryBlobReference is the only supported type. + /// If PendingUploadId is not provided, a random GUID will be used. + /// Name of Azure blob storage connection to use for generating temporary SAS token. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response StartPendingUploadAutoIncrement(string name, PendingUploadType pendingUploadType, string pendingUploadId = null, string connectionName = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + StartPendingUploadAutoIncrementRequest startPendingUploadAutoIncrementRequest = new StartPendingUploadAutoIncrementRequest(pendingUploadId, connectionName, pendingUploadType, null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = StartPendingUploadAutoIncrement(name, startPendingUploadAutoIncrementRequest.ToRequestContent(), context); + return Response.FromValue(PendingUploadResponse.FromResponse(response), response); + } + + /// + /// [Protocol Method] Create or start a pending upload of a dataset. The dataset version will be generated by service. + /// + /// + /// + /// 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 resource. + /// 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 StartPendingUploadAutoIncrementAsync(string name, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.StartPendingUploadAutoIncrement"); + scope.Start(); + try + { + using HttpMessage message = CreateStartPendingUploadAutoIncrementRequest(name, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create or start a pending upload of a dataset. The dataset version will be generated by service. + /// + /// + /// + /// 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 resource. + /// 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 StartPendingUploadAutoIncrement(string name, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Datasets.StartPendingUploadAutoIncrement"); + scope.Start(); + try + { + using HttpMessage message = CreateStartPendingUploadAutoIncrementRequest(name, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List all versions of the given DatasetVersion. + /// The name of the resource. + /// Top count of results, top count cannot be greater than the page size. If topCount is larger than page size, results with be default page size count will be returned. + /// Continuation token for pagination. + /// Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2. + /// [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual AsyncPageable GetVersionsAsync(string name, int? maxCount = null, string skip = null, string tags = null, ListViewType? listViewType = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetVersionsRequest(name, maxCount, skip, tags, listViewType?.ToString(), context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetVersionsNextPageRequest(nextLink, name, maxCount, skip, tags, listViewType?.ToString(), context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => DatasetVersion.DeserializeDatasetVersion(e), ClientDiagnostics, _pipeline, "Datasets.GetVersions", "value", "nextLink", context); + } + + /// List all versions of the given DatasetVersion. + /// The name of the resource. + /// Top count of results, top count cannot be greater than the page size. If topCount is larger than page size, results with be default page size count will be returned. + /// Continuation token for pagination. + /// Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2. + /// [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Pageable GetVersions(string name, int? maxCount = null, string skip = null, string tags = null, ListViewType? listViewType = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetVersionsRequest(name, maxCount, skip, tags, listViewType?.ToString(), context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetVersionsNextPageRequest(nextLink, name, maxCount, skip, tags, listViewType?.ToString(), context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => DatasetVersion.DeserializeDatasetVersion(e), ClientDiagnostics, _pipeline, "Datasets.GetVersions", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List all versions of the given DatasetVersion + /// + /// + /// + /// 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 resource. + /// Top count of results, top count cannot be greater than the page size. If topCount is larger than page size, results with be default page size count will be returned. + /// Continuation token for pagination. + /// Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2. + /// [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. Allowed values: "ActiveOnly" | "ArchivedOnly" | "All". + /// 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 GetVersionsAsync(string name, int? maxCount, string skip, string tags, string listViewType, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetVersionsRequest(name, maxCount, skip, tags, listViewType, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetVersionsNextPageRequest(nextLink, name, maxCount, skip, tags, listViewType, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Datasets.GetVersions", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List all versions of the given DatasetVersion + /// + /// + /// + /// 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 resource. + /// Top count of results, top count cannot be greater than the page size. If topCount is larger than page size, results with be default page size count will be returned. + /// Continuation token for pagination. + /// Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2. + /// [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. Allowed values: "ActiveOnly" | "ArchivedOnly" | "All". + /// 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 GetVersions(string name, int? maxCount, string skip, string tags, string listViewType, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetVersionsRequest(name, maxCount, skip, tags, listViewType, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetVersionsNextPageRequest(nextLink, name, maxCount, skip, tags, listViewType, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Datasets.GetVersions", "value", "nextLink", context); + } + + /// List the latest version of each DatasetVersion. + /// Top count of results, top count cannot be greater than the page size. If topCount is larger than page size, results with be default page size count will be returned. + /// Continuation token for pagination. + /// Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2. + /// [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. + /// The cancellation token to use. + /// + public virtual AsyncPageable GetLatestsAsync(int? maxCount = null, string skip = null, string tags = null, ListViewType? listViewType = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetLatestsRequest(maxCount, skip, tags, listViewType?.ToString(), context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetLatestsNextPageRequest(nextLink, maxCount, skip, tags, listViewType?.ToString(), context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => DatasetVersion.DeserializeDatasetVersion(e), ClientDiagnostics, _pipeline, "Datasets.GetLatests", "value", "nextLink", context); + } + + /// List the latest version of each DatasetVersion. + /// Top count of results, top count cannot be greater than the page size. If topCount is larger than page size, results with be default page size count will be returned. + /// Continuation token for pagination. + /// Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2. + /// [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. + /// The cancellation token to use. + /// + public virtual Pageable GetLatests(int? maxCount = null, string skip = null, string tags = null, ListViewType? listViewType = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetLatestsRequest(maxCount, skip, tags, listViewType?.ToString(), context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetLatestsNextPageRequest(nextLink, maxCount, skip, tags, listViewType?.ToString(), context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => DatasetVersion.DeserializeDatasetVersion(e), ClientDiagnostics, _pipeline, "Datasets.GetLatests", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List the latest version of each DatasetVersion + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Top count of results, top count cannot be greater than the page size. If topCount is larger than page size, results with be default page size count will be returned. + /// Continuation token for pagination. + /// Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2. + /// [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. Allowed values: "ActiveOnly" | "ArchivedOnly" | "All". + /// 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 GetLatestsAsync(int? maxCount, string skip, string tags, string listViewType, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetLatestsRequest(maxCount, skip, tags, listViewType, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetLatestsNextPageRequest(nextLink, maxCount, skip, tags, listViewType, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Datasets.GetLatests", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List the latest version of each DatasetVersion + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Top count of results, top count cannot be greater than the page size. If topCount is larger than page size, results with be default page size count will be returned. + /// Continuation token for pagination. + /// Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2. + /// [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. Allowed values: "ActiveOnly" | "ArchivedOnly" | "All". + /// 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 GetLatests(int? maxCount, string skip, string tags, string listViewType, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetLatestsRequest(maxCount, skip, tags, listViewType, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetLatestsNextPageRequest(nextLink, maxCount, skip, tags, listViewType, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Datasets.GetLatests", "value", "nextLink", context); + } + + internal HttpMessage CreateGetVersionsRequest(string name, int? maxCount, string skip, string tags, string listViewType, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/datasets/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (maxCount != null) + { + uri.AppendQuery("top", maxCount.Value, true); + } + if (skip != null) + { + uri.AppendQuery("skip", skip, true); + } + if (tags != null) + { + uri.AppendQuery("tags", tags, true); + } + if (listViewType != null) + { + uri.AppendQuery("listViewType", listViewType, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetLatestsRequest(int? maxCount, string skip, string tags, string listViewType, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/datasets", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (maxCount != null) + { + uri.AppendQuery("top", maxCount.Value, true); + } + if (skip != null) + { + uri.AppendQuery("skip", skip, true); + } + if (tags != null) + { + uri.AppendQuery("tags", tags, true); + } + if (listViewType != null) + { + uri.AppendQuery("listViewType", listViewType, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetVersionRequest(string name, string version, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/datasets/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(version, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateDeleteVersionRequest(string name, string version, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/datasets/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(version, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateRequest(string name, 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.AppendPath("/datasets/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Repeatability-Request-ID", Guid.NewGuid()); + request.Headers.Add("Repeatability-First-Sent", DateTimeOffset.Now, "R"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateCreateVersionRequest(string name, string version, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/datasets/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(version, 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 CreateStartPendingUploadRequest(string name, string version, 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.AppendPath("/datasets/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(version, true); + uri.AppendPath("/startPendingUpload", 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; + } + + internal HttpMessage CreateStartPendingUploadAutoIncrementRequest(string name, 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.AppendPath("/datasets/", false); + uri.AppendPath(name, true); + uri.AppendPath("/startPendingUpload", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Repeatability-Request-ID", Guid.NewGuid()); + request.Headers.Add("Repeatability-First-Sent", DateTimeOffset.Now, "R"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetVersionsNextPageRequest(string nextLink, string name, int? maxCount, string skip, string tags, string listViewType, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetLatestsNextPageRequest(string nextLink, int? maxCount, string skip, string tags, string listViewType, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + 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 }); + private static ResponseClassifier _responseClassifier204; + private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); + private static ResponseClassifier _responseClassifier200201; + private static ResponseClassifier ResponseClassifier200201 => _responseClassifier200201 ??= new StatusCodeClassifier(stackalloc ushort[] { 200, 201 }); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Deployment.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Deployment.Serialization.cs new file mode 100644 index 000000000000..efbc294a3bd7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Deployment.Serialization.cs @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Projects.OneDP +{ + [PersistableModelProxy(typeof(UnknownDeployment))] + public partial class Deployment : 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(Deployment)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + 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 + } + } + } + + Deployment 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(Deployment)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDeployment(document.RootElement, options); + } + + internal static Deployment DeserializeDeployment(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "ModelDeployment": return ModelDeployment.DeserializeModelDeployment(element, options); + } + } + return UnknownDeployment.DeserializeUnknownDeployment(element, options); + } + + 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(Deployment)} does not support writing '{options.Format}' format."); + } + } + + Deployment 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 DeserializeDeployment(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Deployment)} 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 Deployment FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDeployment(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/ai/Azure.AI.Projects.OneDP/src/Generated/Deployment.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Deployment.cs new file mode 100644 index 000000000000..6f223fa8644d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Deployment.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.Projects.OneDP +{ + /// + /// Model Deployment Definition + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + public abstract partial class Deployment + { + /// + /// 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 protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected Deployment() + { + } + + /// Initializes a new instance of . + /// The type of the deployment. + /// Name of the deployment. + /// Keeps track of any properties unknown to the library. + internal Deployment(DeploymentType type, string name, IDictionary serializedAdditionalRawData) + { + Type = type; + Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The type of the deployment. + internal DeploymentType Type { get; set; } + /// Name of the deployment. + public string Name { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/DeploymentType.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/DeploymentType.cs new file mode 100644 index 000000000000..3c085754aa6e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/DeploymentType.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.Projects.OneDP +{ + /// Represents the type of the deployment. Known literal is 'ModelDeployment'. + internal readonly partial struct DeploymentType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DeploymentType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ModelDeploymentValue = "ModelDeployment"; + + /// Model deployment. + public static DeploymentType ModelDeployment { get; } = new DeploymentType(ModelDeploymentValue); + /// Determines if two values are the same. + public static bool operator ==(DeploymentType left, DeploymentType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DeploymentType left, DeploymentType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator DeploymentType(string value) => new DeploymentType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DeploymentType other && Equals(other); + /// + public bool Equals(DeploymentType 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/ai/Azure.AI.Projects.OneDP/src/Generated/Deployments.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Deployments.cs new file mode 100644 index 000000000000..0fe9ff5822b0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Deployments.cs @@ -0,0 +1,346 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Projects.OneDP +{ + // Data plane generated sub-client. + /// The Deployments sub-client. + public partial class Deployments + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + 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 Deployments for mocking. + protected Deployments() + { + } + + /// Initializes a new instance of Deployments. + /// 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. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// The API version to use for this operation. + internal Deployments(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Get a deployed model. + /// Name of the deployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetDeploymentAsync(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetDeploymentAsync(name, context).ConfigureAwait(false); + return Response.FromValue(Deployment.FromResponse(response), response); + } + + /// Get a deployed model. + /// Name of the deployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetDeployment(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetDeployment(name, context); + return Response.FromValue(Deployment.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get a deployed model. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Name of the deployment. + /// 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 GetDeploymentAsync(string name, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = ClientDiagnostics.CreateScope("Deployments.GetDeployment"); + scope.Start(); + try + { + using HttpMessage message = CreateGetDeploymentRequest(name, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get a deployed model. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Name of the deployment. + /// 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 GetDeployment(string name, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = ClientDiagnostics.CreateScope("Deployments.GetDeployment"); + scope.Start(); + try + { + using HttpMessage message = CreateGetDeploymentRequest(name, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List all deployed models in the project. + /// Model publisher to filter models by. + /// Model name (the publisher specific name) to filter models by. + /// Flag to include models from connections in response. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// + public virtual AsyncPageable GetDeploymentsAsync(string modelPublisher = null, string modelName = null, bool? includeConnectionModels = null, 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) => CreateGetDeploymentsRequest(modelPublisher, modelName, includeConnectionModels, maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDeploymentsNextPageRequest(nextLink, modelPublisher, modelName, includeConnectionModels, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Deployment.DeserializeDeployment(e), ClientDiagnostics, _pipeline, "Deployments.GetDeployments", "value", "nextLink", maxpagesize, context); + } + + /// List all deployed models in the project. + /// Model publisher to filter models by. + /// Model name (the publisher specific name) to filter models by. + /// Flag to include models from connections in response. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// + public virtual Pageable GetDeployments(string modelPublisher = null, string modelName = null, bool? includeConnectionModels = null, 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) => CreateGetDeploymentsRequest(modelPublisher, modelName, includeConnectionModels, maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDeploymentsNextPageRequest(nextLink, modelPublisher, modelName, includeConnectionModels, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Deployment.DeserializeDeployment(e), ClientDiagnostics, _pipeline, "Deployments.GetDeployments", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] List all deployed models in the project + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Model publisher to filter models by. + /// Model name (the publisher specific name) to filter models by. + /// Flag to include models from connections in response. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// 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 GetDeploymentsAsync(string modelPublisher, string modelName, bool? includeConnectionModels, int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDeploymentsRequest(modelPublisher, modelName, includeConnectionModels, maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDeploymentsNextPageRequest(nextLink, modelPublisher, modelName, includeConnectionModels, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Deployments.GetDeployments", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] List all deployed models in the project + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Model publisher to filter models by. + /// Model name (the publisher specific name) to filter models by. + /// Flag to include models from connections in response. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// 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 GetDeployments(string modelPublisher, string modelName, bool? includeConnectionModels, int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetDeploymentsRequest(modelPublisher, modelName, includeConnectionModels, maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetDeploymentsNextPageRequest(nextLink, modelPublisher, modelName, includeConnectionModels, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Deployments.GetDeployments", "value", "nextLink", maxpagesize, context); + } + + internal HttpMessage CreateGetDeploymentRequest(string name, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/deployments/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetDeploymentsRequest(string modelPublisher, string modelName, bool? includeConnectionModels, int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/deployments", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (modelPublisher != null) + { + uri.AppendQuery("modelPublisher", modelPublisher, true); + } + if (modelName != null) + { + uri.AppendQuery("modelName", modelName, true); + } + if (includeConnectionModels != null) + { + uri.AppendQuery("includeConnectedModels", includeConnectionModels.Value, 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 CreateGetDeploymentsNextPageRequest(string nextLink, string modelPublisher, string modelName, bool? includeConnectionModels, int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + 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/ai/Azure.AI.Projects.OneDP/src/Generated/DeveloperMessage.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/DeveloperMessage.Serialization.cs new file mode 100644 index 000000000000..bc300b2731df --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/DeveloperMessage.Serialization.cs @@ -0,0 +1,204 @@ +// 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.Projects.OneDP +{ + public partial class DeveloperMessage : 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 override 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(DeveloperMessage)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + DeveloperMessage 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(DeveloperMessage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDeveloperMessage(document.RootElement, options); + } + + internal static DeveloperMessage DeserializeDeveloperMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string userId = default; + string agentId = default; + string messageId = default; + string agentRunId = default; + string conversationId = default; + AuthorRole role = default; + IList content = default; + string authorName = default; + long? createdAt = default; + long? completedAt = 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("agentId"u8)) + { + agentId = property.Value.GetString(); + continue; + } + if (property.NameEquals("messageId"u8)) + { + messageId = property.Value.GetString(); + continue; + } + if (property.NameEquals("agentRunId"u8)) + { + agentRunId = property.Value.GetString(); + continue; + } + if (property.NameEquals("conversationId"u8)) + { + conversationId = property.Value.GetString(); + continue; + } + if (property.NameEquals("role"u8)) + { + role = new AuthorRole(property.Value.GetString()); + continue; + } + if (property.NameEquals("content"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AIContent.DeserializeAIContent(item, options)); + } + content = array; + continue; + } + if (property.NameEquals("authorName"u8)) + { + authorName = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdAt = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("completedAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + completedAt = property.Value.GetInt64(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DeveloperMessage( + userId, + agentId, + messageId, + agentRunId, + conversationId, + role, + content, + authorName, + createdAt, + completedAt, + 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(DeveloperMessage)} does not support writing '{options.Format}' format."); + } + } + + DeveloperMessage 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 DeserializeDeveloperMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DeveloperMessage)} 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 new DeveloperMessage FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDeveloperMessage(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/DeveloperMessage.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/DeveloperMessage.cs new file mode 100644 index 000000000000..c136dd7de229 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/DeveloperMessage.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// A developer message within a chat, always with the 'developer' role. + public partial class DeveloperMessage : ChatMessage + { + /// Initializes a new instance of . + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// is null. + public DeveloperMessage(IEnumerable content) : base(content) + { + Argument.AssertNotNull(content, nameof(content)); + + Role = AuthorRole.Developer; + } + + /// Initializes a new instance of . + /// The ID of the user who created the message (if applicable). + /// The ID of the agent who created the message (if applicable). + /// A unique identifier for this message. + /// A unique run ID, if this message was generated by a run process. + /// The conversation to which this message belongs. + /// The role of this message's author. + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// An optional display name for the author. + /// The timestamp (in Unix time) when this message was created. + /// The timestamp (in Unix time) when this message was completed, if applicable. + /// Keeps track of any properties unknown to the library. + internal DeveloperMessage(string userId, string agentId, string messageId, string agentRunId, string conversationId, AuthorRole role, IList content, string authorName, long? createdAt, long? completedAt, IDictionary serializedAdditionalRawData) : base(userId, agentId, messageId, agentRunId, conversationId, role, content, authorName, createdAt, completedAt, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal DeveloperMessage() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Agents.xml b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Agents.xml new file mode 100644 index 000000000000..932c1378ac70 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Agents.xml @@ -0,0 +1,2591 @@ + + + + + +This sample shows how to call CreateAgentAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.CreateAgentAsync(""); +]]> +This sample shows how to call CreateAgentAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +AgentModel agentModel = new OpenAIAgentModel("", new JSONAny()) +{ + Endpoint = "", +}; +ToolChoiceBehavior toolChoice = new AutoToolChoiceBehavior(new string[] { "" }); +Response response = await client.CreateAgentAsync("", agentModel: agentModel, instructions: "", tools: new AgentToolDefinition[] +{ + new FunctionToolDefinition("") + { + Description = "", + Parameters = new JSONSchema("", new Dictionary + { + ["key"] = default + }) + { + Required = {""}, + }, + Strict = true, + Options = default, + Override = new AgentToolDefinitionOverride + { + Name = "", + Description = "", + Parameters = default, + }, + } +}, toolChoice: toolChoice); +]]> + + + +This sample shows how to call CreateAgent. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.CreateAgent(""); +]]> +This sample shows how to call CreateAgent with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +AgentModel agentModel = new OpenAIAgentModel("", new JSONAny()) +{ + Endpoint = "", +}; +ToolChoiceBehavior toolChoice = new AutoToolChoiceBehavior(new string[] { "" }); +Response response = client.CreateAgent("", agentModel: agentModel, instructions: "", tools: new AgentToolDefinition[] +{ + new FunctionToolDefinition("") + { + Description = "", + Parameters = new JSONSchema("", new Dictionary + { + ["key"] = default + }) + { + Required = {""}, + }, + Strict = true, + Options = default, + Override = new AgentToolDefinitionOverride + { + Name = "", + Description = "", + Parameters = default, + }, + } +}, toolChoice: toolChoice); +]]> + + + +This sample shows how to call CreateAgentAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + displayName = "", +}); +Response response = await client.CreateAgentAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); +]]> +This sample shows how to call CreateAgentAsync with all request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + displayName = "", + agentModel = new + { + provider = "openai", + options = new + { + temperature = 123.45F, + topP = 123.45F, + }, + id = "", + endpoint = "", + }, + instructions = "", + tools = new object[] + { + new Dictionary + { + ["type"] = "Function", + ["name"] = "", + ["description"] = "", + ["parameters"] = new + { + type = "", + properties = new {}, + required = new object[] + { + "" + }, + }, + ["strict"] = true, + ["options"] = null, + ["override"] = new + { + name = "", + description = "", + } + } + }, + toolChoice = new + { + type = "auto", + toolNames = new object[] + { + "" + }, + }, +}); +Response response = await client.CreateAgentAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("provider").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("endpoint").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("instructions").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("toolChoice").GetProperty("type").ToString()); +]]> + + + +This sample shows how to call CreateAgent and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + displayName = "", +}); +Response response = client.CreateAgent(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); +]]> +This sample shows how to call CreateAgent with all request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + displayName = "", + agentModel = new + { + provider = "openai", + options = new + { + temperature = 123.45F, + topP = 123.45F, + }, + id = "", + endpoint = "", + }, + instructions = "", + tools = new object[] + { + new Dictionary + { + ["type"] = "Function", + ["name"] = "", + ["description"] = "", + ["parameters"] = new + { + type = "", + properties = new {}, + required = new object[] + { + "" + }, + }, + ["strict"] = true, + ["options"] = null, + ["override"] = new + { + name = "", + description = "", + } + } + }, + toolChoice = new + { + type = "auto", + toolNames = new object[] + { + "" + }, + }, +}); +Response response = client.CreateAgent(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("provider").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("endpoint").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("instructions").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("toolChoice").GetProperty("type").ToString()); +]]> + + + +This sample shows how to call GetAgentAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetAgentAsync(""); +]]> +This sample shows how to call GetAgentAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetAgentAsync(""); +]]> + + + +This sample shows how to call GetAgent. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetAgent(""); +]]> +This sample shows how to call GetAgent with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetAgent(""); +]]> + + + +This sample shows how to call GetAgentAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetAgentAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); +]]> +This sample shows how to call GetAgentAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetAgentAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("provider").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("endpoint").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("instructions").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("toolChoice").GetProperty("type").ToString()); +]]> + + + +This sample shows how to call GetAgent and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetAgent("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); +]]> +This sample shows how to call GetAgent with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetAgent("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("provider").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("endpoint").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("instructions").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("toolChoice").GetProperty("type").ToString()); +]]> + + + +This sample shows how to call UpdateAgentAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Agent body = new Agent(new AgentConfigurationOptions("")); +Response response = await client.UpdateAgentAsync("", body); +]]> +This sample shows how to call UpdateAgentAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Agent body = new Agent(new AgentConfigurationOptions("") +{ + AgentModel = new OpenAIAgentModel("", new JSONAny()) + { + Endpoint = "", + }, + Instructions = "", + Tools = {new FunctionToolDefinition("") + { + Description = "", + Parameters = new JSONSchema("", new Dictionary + { + ["key"] = default + }) + { + Required = {""}, + }, + Strict = true, + Options = default, + Override = new AgentToolDefinitionOverride + { + Name = "", + Description = "", + Parameters = default, + }, + }}, + ToolChoice = new AutoToolChoiceBehavior(new string[] { "" }), +}) +{ + Description = "", + Metadata = + { + ["key"] = "" + }, +}; +Response response = await client.UpdateAgentAsync("", body); +]]> + + + +This sample shows how to call UpdateAgent. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Agent body = new Agent(new AgentConfigurationOptions("")); +Response response = client.UpdateAgent("", body); +]]> +This sample shows how to call UpdateAgent with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Agent body = new Agent(new AgentConfigurationOptions("") +{ + AgentModel = new OpenAIAgentModel("", new JSONAny()) + { + Endpoint = "", + }, + Instructions = "", + Tools = {new FunctionToolDefinition("") + { + Description = "", + Parameters = new JSONSchema("", new Dictionary + { + ["key"] = default + }) + { + Required = {""}, + }, + Strict = true, + Options = default, + Override = new AgentToolDefinitionOverride + { + Name = "", + Description = "", + Parameters = default, + }, + }}, + ToolChoice = new AutoToolChoiceBehavior(new string[] { "" }), +}) +{ + Description = "", + Metadata = + { + ["key"] = "" + }, +}; +Response response = client.UpdateAgent("", body); +]]> + + + +This sample shows how to call UpdateAgentAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + configurationOptions = new + { + displayName = "", + }, +}); +Response response = await client.UpdateAgentAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); +]]> +This sample shows how to call UpdateAgentAsync with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + description = "", + metadata = new + { + key = "", + }, + configurationOptions = new + { + displayName = "", + agentModel = new + { + provider = "openai", + options = new + { + temperature = 123.45F, + topP = 123.45F, + }, + id = "", + endpoint = "", + }, + instructions = "", + tools = new object[] + { + new Dictionary + { + ["type"] = "Function", + ["name"] = "", + ["description"] = "", + ["parameters"] = new + { + type = "", + properties = new {}, + required = new object[] + { + "" + }, + }, + ["strict"] = true, + ["options"] = null, + ["override"] = new + { + name = "", + description = "", + } + } + }, + toolChoice = new + { + type = "auto", + toolNames = new object[] + { + "" + }, + }, + }, +}); +Response response = await client.UpdateAgentAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("provider").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("endpoint").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("instructions").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("toolChoice").GetProperty("type").ToString()); +]]> + + + +This sample shows how to call UpdateAgent and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + configurationOptions = new + { + displayName = "", + }, +}); +Response response = client.UpdateAgent("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); +]]> +This sample shows how to call UpdateAgent with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + description = "", + metadata = new + { + key = "", + }, + configurationOptions = new + { + displayName = "", + agentModel = new + { + provider = "openai", + options = new + { + temperature = 123.45F, + topP = 123.45F, + }, + id = "", + endpoint = "", + }, + instructions = "", + tools = new object[] + { + new Dictionary + { + ["type"] = "Function", + ["name"] = "", + ["description"] = "", + ["parameters"] = new + { + type = "", + properties = new {}, + required = new object[] + { + "" + }, + }, + ["strict"] = true, + ["options"] = null, + ["override"] = new + { + name = "", + description = "", + } + } + }, + toolChoice = new + { + type = "auto", + toolNames = new object[] + { + "" + }, + }, + }, +}); +Response response = client.UpdateAgent("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("provider").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("endpoint").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("instructions").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); +Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("toolChoice").GetProperty("type").ToString()); +]]> + + + +This sample shows how to call DeleteAgentAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.DeleteAgentAsync(""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteAgentAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.DeleteAgentAsync(""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call DeleteAgent. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.DeleteAgent(""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteAgent with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.DeleteAgent(""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call GetAgentsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response> response = await client.GetAgentsAsync(); +]]> +This sample shows how to call GetAgentsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response> response = await client.GetAgentsAsync(); +]]> + + + +This sample shows how to call GetAgents. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response> response = client.GetAgents(); +]]> +This sample shows how to call GetAgents with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response> response = client.GetAgents(); +]]> + + + +This sample shows how to call GetAgentsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetAgentsAsync(null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result[0].GetProperty("agentId").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("displayName").ToString()); +]]> +This sample shows how to call GetAgentsAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetAgentsAsync(null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result[0].GetProperty("agentId").ToString()); +Console.WriteLine(result[0].GetProperty("description").ToString()); +Console.WriteLine(result[0].GetProperty("metadata").GetProperty("").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("displayName").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("id").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("provider").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("endpoint").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("instructions").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("type").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("toolChoice").GetProperty("type").ToString()); +]]> + + + +This sample shows how to call GetAgents and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetAgents(null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result[0].GetProperty("agentId").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("displayName").ToString()); +]]> +This sample shows how to call GetAgents with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetAgents(null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result[0].GetProperty("agentId").ToString()); +Console.WriteLine(result[0].GetProperty("description").ToString()); +Console.WriteLine(result[0].GetProperty("metadata").GetProperty("").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("displayName").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("id").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("provider").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("endpoint").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("instructions").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("type").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); +Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("toolChoice").GetProperty("type").ToString()); +]]> + + + +This sample shows how to call RunAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.RunAsync(new ChatMessage[] +{ + new UserMessage(new AIContent[] + { + new TextContent("") + }) +}); +]]> +This sample shows how to call RunAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +RunOptions options = new RunOptions +{ + TruncationStrategy = new TruncationStrategy(TruncationStrategyType.Auto) + { + LastMessages = 1234, + }, +}; +AgentConfigurationOptions agentConfiguration = new AgentConfigurationOptions("") +{ + AgentModel = new OpenAIAgentModel("", new JSONAny()) + { + Endpoint = "", + }, + Instructions = "", + Tools = {new FunctionToolDefinition("") + { + Description = "", + Parameters = new JSONSchema("", new Dictionary + { + ["key"] = default + }) + { + Required = {""}, + }, + Strict = true, + Options = default, + Override = new AgentToolDefinitionOverride + { + Name = "", + Description = "", + Parameters = default, + }, + }}, + ToolChoice = new AutoToolChoiceBehavior(new string[] { "" }), +}; +Response response = await client.RunAsync(new ChatMessage[] +{ + new UserMessage(new AIContent[] + { + new TextContent("") + { + Annotations = {new Annotations("") + { + ToolCallId = "", + JsonPath = "", + Url = "", + Start = 1234, + End = 1234, + }}, + } + }) + { + UserId = "", + AgentId = "", + AgentRunId = "", + AuthorName = "", + CreatedAt = 1234L, + CompletedAt = 1234L, + } +}, agentId: "", conversationId: "", metadata: new Dictionary +{ + ["key"] = "" +}, options: options, userId: "", agentConfiguration: agentConfiguration); +]]> + + + +This sample shows how to call Run. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.Run(new ChatMessage[] +{ + new UserMessage(new AIContent[] + { + new TextContent("") + }) +}); +]]> +This sample shows how to call Run with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +RunOptions options = new RunOptions +{ + TruncationStrategy = new TruncationStrategy(TruncationStrategyType.Auto) + { + LastMessages = 1234, + }, +}; +AgentConfigurationOptions agentConfiguration = new AgentConfigurationOptions("") +{ + AgentModel = new OpenAIAgentModel("", new JSONAny()) + { + Endpoint = "", + }, + Instructions = "", + Tools = {new FunctionToolDefinition("") + { + Description = "", + Parameters = new JSONSchema("", new Dictionary + { + ["key"] = default + }) + { + Required = {""}, + }, + Strict = true, + Options = default, + Override = new AgentToolDefinitionOverride + { + Name = "", + Description = "", + Parameters = default, + }, + }}, + ToolChoice = new AutoToolChoiceBehavior(new string[] { "" }), +}; +Response response = client.Run(new ChatMessage[] +{ + new UserMessage(new AIContent[] + { + new TextContent("") + { + Annotations = {new Annotations("") + { + ToolCallId = "", + JsonPath = "", + Url = "", + Start = 1234, + End = 1234, + }}, + } + }) + { + UserId = "", + AgentId = "", + AgentRunId = "", + AuthorName = "", + CreatedAt = 1234L, + CompletedAt = 1234L, + } +}, agentId: "", conversationId: "", metadata: new Dictionary +{ + ["key"] = "" +}, options: options, userId: "", agentConfiguration: agentConfiguration); +]]> + + + +This sample shows how to call RunAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + input = new object[] + { + new + { + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + } + }, + } + }, +}); +Response response = await client.RunAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("runId").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); +]]> +This sample shows how to call RunAsync with all request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + agentId = "", + input = new object[] + { + new + { + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + annotations = new object[] + { + new + { + type = "", + ToolCallId = "", + jsonPath = "", + url = "", + start = 1234, + end = 1234, + } + }, + } + }, + userId = "", + agentId = "", + agentRunId = "", + authorName = "", + createdAt = 1234L, + completedAt = 1234L, + } + }, + conversationId = "", + metadata = new + { + key = "", + }, + options = new + { + truncationStrategy = new + { + type = "auto", + lastMessages = 1234, + }, + }, + userId = "", + agentConfiguration = new + { + displayName = "", + agentModel = new + { + provider = "openai", + options = new + { + temperature = 123.45F, + topP = 123.45F, + }, + id = "", + endpoint = "", + }, + instructions = "", + tools = new object[] + { + new Dictionary + { + ["type"] = "Function", + ["name"] = "", + ["description"] = "", + ["parameters"] = new + { + type = "", + properties = new {}, + required = new object[] + { + "" + }, + }, + ["strict"] = true, + ["options"] = null, + ["override"] = new + { + name = "", + description = "", + } + } + }, + toolChoice = new + { + type = "auto", + toolNames = new object[] + { + "" + }, + }, + }, +}); +Response response = await client.RunAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("runId").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("metadata").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("lastMessages").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("provider").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("endpoint").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("instructions").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("toolChoice").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("store").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokenDetails").GetProperty("cachedTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokenDetails").GetProperty("reasoningTokens").ToString()); +Console.WriteLine(result.GetProperty("incompleteDetails").GetProperty("reason").ToString()); +]]> + + + +This sample shows how to call Run and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + input = new object[] + { + new + { + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + } + }, + } + }, +}); +Response response = client.Run(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("runId").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); +]]> +This sample shows how to call Run with all request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + agentId = "", + input = new object[] + { + new + { + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + annotations = new object[] + { + new + { + type = "", + ToolCallId = "", + jsonPath = "", + url = "", + start = 1234, + end = 1234, + } + }, + } + }, + userId = "", + agentId = "", + agentRunId = "", + authorName = "", + createdAt = 1234L, + completedAt = 1234L, + } + }, + conversationId = "", + metadata = new + { + key = "", + }, + options = new + { + truncationStrategy = new + { + type = "auto", + lastMessages = 1234, + }, + }, + userId = "", + agentConfiguration = new + { + displayName = "", + agentModel = new + { + provider = "openai", + options = new + { + temperature = 123.45F, + topP = 123.45F, + }, + id = "", + endpoint = "", + }, + instructions = "", + tools = new object[] + { + new Dictionary + { + ["type"] = "Function", + ["name"] = "", + ["description"] = "", + ["parameters"] = new + { + type = "", + properties = new {}, + required = new object[] + { + "" + }, + }, + ["strict"] = true, + ["options"] = null, + ["override"] = new + { + name = "", + description = "", + } + } + }, + toolChoice = new + { + type = "auto", + toolNames = new object[] + { + "" + }, + }, + }, +}); +Response response = client.Run(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("runId").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("metadata").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("lastMessages").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("provider").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("endpoint").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("instructions").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("toolChoice").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("store").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokenDetails").GetProperty("cachedTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokenDetails").GetProperty("reasoningTokens").ToString()); +Console.WriteLine(result.GetProperty("incompleteDetails").GetProperty("reason").ToString()); +]]> + + + +This sample shows how to call StreamAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.StreamAsync(new ChatMessage[] +{ + new UserMessage(new AIContent[] + { + new TextContent("") + }) +}); +]]> +This sample shows how to call StreamAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +RunOptions options = new RunOptions +{ + TruncationStrategy = new TruncationStrategy(TruncationStrategyType.Auto) + { + LastMessages = 1234, + }, +}; +AgentConfigurationOptions agentConfiguration = new AgentConfigurationOptions("") +{ + AgentModel = new OpenAIAgentModel("", new JSONAny()) + { + Endpoint = "", + }, + Instructions = "", + Tools = {new FunctionToolDefinition("") + { + Description = "", + Parameters = new JSONSchema("", new Dictionary + { + ["key"] = default + }) + { + Required = {""}, + }, + Strict = true, + Options = default, + Override = new AgentToolDefinitionOverride + { + Name = "", + Description = "", + Parameters = default, + }, + }}, + ToolChoice = new AutoToolChoiceBehavior(new string[] { "" }), +}; +Response response = await client.StreamAsync(new ChatMessage[] +{ + new UserMessage(new AIContent[] + { + new TextContent("") + { + Annotations = {new Annotations("") + { + ToolCallId = "", + JsonPath = "", + Url = "", + Start = 1234, + End = 1234, + }}, + } + }) + { + UserId = "", + AgentId = "", + AgentRunId = "", + AuthorName = "", + CreatedAt = 1234L, + CompletedAt = 1234L, + } +}, agentId: "", conversationId: "", metadata: new Dictionary +{ + ["key"] = "" +}, options: options, userId: "", agentConfiguration: agentConfiguration); +]]> + + + +This sample shows how to call Stream. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.Stream(new ChatMessage[] +{ + new UserMessage(new AIContent[] + { + new TextContent("") + }) +}); +]]> +This sample shows how to call Stream with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +RunOptions options = new RunOptions +{ + TruncationStrategy = new TruncationStrategy(TruncationStrategyType.Auto) + { + LastMessages = 1234, + }, +}; +AgentConfigurationOptions agentConfiguration = new AgentConfigurationOptions("") +{ + AgentModel = new OpenAIAgentModel("", new JSONAny()) + { + Endpoint = "", + }, + Instructions = "", + Tools = {new FunctionToolDefinition("") + { + Description = "", + Parameters = new JSONSchema("", new Dictionary + { + ["key"] = default + }) + { + Required = {""}, + }, + Strict = true, + Options = default, + Override = new AgentToolDefinitionOverride + { + Name = "", + Description = "", + Parameters = default, + }, + }}, + ToolChoice = new AutoToolChoiceBehavior(new string[] { "" }), +}; +Response response = client.Stream(new ChatMessage[] +{ + new UserMessage(new AIContent[] + { + new TextContent("") + { + Annotations = {new Annotations("") + { + ToolCallId = "", + JsonPath = "", + Url = "", + Start = 1234, + End = 1234, + }}, + } + }) + { + UserId = "", + AgentId = "", + AgentRunId = "", + AuthorName = "", + CreatedAt = 1234L, + CompletedAt = 1234L, + } +}, agentId: "", conversationId: "", metadata: new Dictionary +{ + ["key"] = "" +}, options: options, userId: "", agentConfiguration: agentConfiguration); +]]> + + + +This sample shows how to call StreamAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + input = new object[] + { + new + { + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + } + }, + } + }, +}); +Response response = await client.StreamAsync(content); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call StreamAsync with all request content. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + agentId = "", + input = new object[] + { + new + { + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + annotations = new object[] + { + new + { + type = "", + ToolCallId = "", + jsonPath = "", + url = "", + start = 1234, + end = 1234, + } + }, + } + }, + userId = "", + agentId = "", + agentRunId = "", + authorName = "", + createdAt = 1234L, + completedAt = 1234L, + } + }, + conversationId = "", + metadata = new + { + key = "", + }, + options = new + { + truncationStrategy = new + { + type = "auto", + lastMessages = 1234, + }, + }, + userId = "", + agentConfiguration = new + { + displayName = "", + agentModel = new + { + provider = "openai", + options = new + { + temperature = 123.45F, + topP = 123.45F, + }, + id = "", + endpoint = "", + }, + instructions = "", + tools = new object[] + { + new Dictionary + { + ["type"] = "Function", + ["name"] = "", + ["description"] = "", + ["parameters"] = new + { + type = "", + properties = new {}, + required = new object[] + { + "" + }, + }, + ["strict"] = true, + ["options"] = null, + ["override"] = new + { + name = "", + description = "", + } + } + }, + toolChoice = new + { + type = "auto", + toolNames = new object[] + { + "" + }, + }, + }, +}); +Response response = await client.StreamAsync(content); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call Stream. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + input = new object[] + { + new + { + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + } + }, + } + }, +}); +Response response = client.Stream(content); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call Stream with all request content. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + agentId = "", + input = new object[] + { + new + { + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + annotations = new object[] + { + new + { + type = "", + ToolCallId = "", + jsonPath = "", + url = "", + start = 1234, + end = 1234, + } + }, + } + }, + userId = "", + agentId = "", + agentRunId = "", + authorName = "", + createdAt = 1234L, + completedAt = 1234L, + } + }, + conversationId = "", + metadata = new + { + key = "", + }, + options = new + { + truncationStrategy = new + { + type = "auto", + lastMessages = 1234, + }, + }, + userId = "", + agentConfiguration = new + { + displayName = "", + agentModel = new + { + provider = "openai", + options = new + { + temperature = 123.45F, + topP = 123.45F, + }, + id = "", + endpoint = "", + }, + instructions = "", + tools = new object[] + { + new Dictionary + { + ["type"] = "Function", + ["name"] = "", + ["description"] = "", + ["parameters"] = new + { + type = "", + properties = new {}, + required = new object[] + { + "" + }, + }, + ["strict"] = true, + ["options"] = null, + ["override"] = new + { + name = "", + description = "", + } + } + }, + toolChoice = new + { + type = "auto", + toolNames = new object[] + { + "" + }, + }, + }, +}); +Response response = client.Stream(content); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call GetRunAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetRunAsync(""); +]]> +This sample shows how to call GetRunAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetRunAsync(""); +]]> + + + +This sample shows how to call GetRun. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetRun(""); +]]> +This sample shows how to call GetRun with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetRun(""); +]]> + + + +This sample shows how to call GetRunAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetRunAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("runId").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); +]]> +This sample shows how to call GetRunAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetRunAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("runId").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("metadata").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("lastMessages").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("provider").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("endpoint").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("instructions").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("toolChoice").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("store").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokenDetails").GetProperty("cachedTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokenDetails").GetProperty("reasoningTokens").ToString()); +Console.WriteLine(result.GetProperty("incompleteDetails").GetProperty("reason").ToString()); +]]> + + + +This sample shows how to call GetRun and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetRun("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("runId").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); +]]> +This sample shows how to call GetRun with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetRun("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("runId").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("metadata").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("lastMessages").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("provider").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("endpoint").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("instructions").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); +Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("toolChoice").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("store").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("output")[0].GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokenDetails").GetProperty("cachedTokens").ToString()); +Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokenDetails").GetProperty("reasoningTokens").ToString()); +Console.WriteLine(result.GetProperty("incompleteDetails").GetProperty("reason").ToString()); +]]> + + + +This sample shows how to call GetRunInputsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetRunInputsAsync(""); +]]> +This sample shows how to call GetRunInputsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetRunInputsAsync(""); +]]> + + + +This sample shows how to call GetRunInputs. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetRunInputs(""); +]]> +This sample shows how to call GetRunInputs with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetRunInputs(""); +]]> + + + +This sample shows how to call GetRunInputsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetRunInputsAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("input")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); +]]> +This sample shows how to call GetRunInputsAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetRunInputsAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("options").GetProperty("truncationStrategy").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("options").GetProperty("truncationStrategy").GetProperty("lastMessages").ToString()); +Console.WriteLine(result.GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("provider").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("endpoint").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("instructions").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("toolChoice").GetProperty("type").ToString()); +]]> + + + +This sample shows how to call GetRunInputs and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetRunInputs("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("input")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); +]]> +This sample shows how to call GetRunInputs with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetRunInputs("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("input")[0].GetProperty("completedAt").ToString()); +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("options").GetProperty("truncationStrategy").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("options").GetProperty("truncationStrategy").GetProperty("lastMessages").ToString()); +Console.WriteLine(result.GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("provider").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("endpoint").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("instructions").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); +Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("toolChoice").GetProperty("type").ToString()); +]]> + + + +This sample shows how to call GetRunsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +await foreach (Run item in client.GetRunsAsync()) +{ +} +]]> +This sample shows how to call GetRunsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +await foreach (Run item in client.GetRunsAsync()) +{ +} +]]> + + + +This sample shows how to call GetRuns. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +foreach (Run item in client.GetRuns()) +{ +} +]]> +This sample shows how to call GetRuns with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +foreach (Run item in client.GetRuns()) +{ +} +]]> + + + +This sample shows how to call GetRunsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +await foreach (BinaryData item in client.GetRunsAsync(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("runId").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); +} +]]> +This sample shows how to call GetRunsAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +await foreach (BinaryData item in client.GetRunsAsync(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("runId").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("lastMessages").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("provider").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("endpoint").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("instructions").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("toolChoice").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("store").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokenDetails").GetProperty("cachedTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokenDetails").GetProperty("reasoningTokens").ToString()); + Console.WriteLine(result.GetProperty("incompleteDetails").GetProperty("reason").ToString()); +} +]]> + + + +This sample shows how to call GetRuns and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +foreach (BinaryData item in client.GetRuns(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("runId").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); +} +]]> +This sample shows how to call GetRuns with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + +foreach (BinaryData item in client.GetRuns(null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("runId").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("lastMessages").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("provider").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("endpoint").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("instructions").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("toolChoice").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("store").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokenDetails").GetProperty("cachedTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokenDetails").GetProperty("reasoningTokens").ToString()); + Console.WriteLine(result.GetProperty("incompleteDetails").GetProperty("reason").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Connections.xml b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Connections.xml new file mode 100644 index 000000000000..bb44b3550ff1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Connections.xml @@ -0,0 +1,217 @@ + + + + + +This sample shows how to call GetConnectionAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetConnectionAsync(""); +]]> +This sample shows how to call GetConnectionAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetConnectionAsync(""); +]]> + + + +This sample shows how to call GetConnection. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetConnection(""); +]]> +This sample shows how to call GetConnection with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetConnection(""); +]]> + + + +This sample shows how to call GetConnectionAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetConnectionAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("target").ToString()); +Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); +]]> +This sample shows how to call GetConnectionAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetConnectionAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("target").ToString()); +Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); +]]> + + + +This sample shows how to call GetConnection and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetConnection("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("target").ToString()); +Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); +]]> +This sample shows how to call GetConnection with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetConnection("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("target").ToString()); +Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); +]]> + + + +This sample shows how to call GetConnectionsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + +await foreach (Connection item in client.GetConnectionsAsync()) +{ +} +]]> +This sample shows how to call GetConnectionsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + +await foreach (Connection item in client.GetConnectionsAsync(connectionType: ConnectionType.AzureOpenAI, maxCount: 1234, skip: 1234, maxpagesize: 1234)) +{ +} +]]> + + + +This sample shows how to call GetConnections. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + +foreach (Connection item in client.GetConnections()) +{ +} +]]> +This sample shows how to call GetConnections with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + +foreach (Connection item in client.GetConnections(connectionType: ConnectionType.AzureOpenAI, maxCount: 1234, skip: 1234, maxpagesize: 1234)) +{ +} +]]> + + + +This sample shows how to call GetConnectionsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + +await foreach (BinaryData item in client.GetConnectionsAsync(null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); +} +]]> +This sample shows how to call GetConnectionsAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + +await foreach (BinaryData item in client.GetConnectionsAsync("AzureOpenAI", 1234, 1234, 1234, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); +} +]]> + + + +This sample shows how to call GetConnections and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + +foreach (BinaryData item in client.GetConnections(null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); +} +]]> +This sample shows how to call GetConnections with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + +foreach (BinaryData item in client.GetConnections("AzureOpenAI", 1234, 1234, 1234, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Conversations.xml b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Conversations.xml new file mode 100644 index 000000000000..6d2288586595 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Conversations.xml @@ -0,0 +1,855 @@ + + + + + +This sample shows how to call CreateConversationAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.CreateConversationAsync(new ChatMessage[] +{ + new UserMessage(new AIContent[] + { + new TextContent("") + }) +}); +]]> +This sample shows how to call CreateConversationAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.CreateConversationAsync(new ChatMessage[] +{ + new UserMessage(new AIContent[] + { + new TextContent("") + { + Annotations = {new Annotations("") + { + ToolCallId = "", + JsonPath = "", + Url = "", + Start = 1234, + End = 1234, + }}, + } + }) + { + UserId = "", + AgentId = "", + AgentRunId = "", + AuthorName = "", + CreatedAt = 1234L, + CompletedAt = 1234L, + } +}); +]]> + + + +This sample shows how to call CreateConversation. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.CreateConversation(new ChatMessage[] +{ + new UserMessage(new AIContent[] + { + new TextContent("") + }) +}); +]]> +This sample shows how to call CreateConversation with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.CreateConversation(new ChatMessage[] +{ + new UserMessage(new AIContent[] + { + new TextContent("") + { + Annotations = {new Annotations("") + { + ToolCallId = "", + JsonPath = "", + Url = "", + Start = 1234, + End = 1234, + }}, + } + }) + { + UserId = "", + AgentId = "", + AgentRunId = "", + AuthorName = "", + CreatedAt = 1234L, + CompletedAt = 1234L, + } +}); +]]> + + + +This sample shows how to call CreateConversationAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + messages = new object[] + { + new + { + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + } + }, + } + }, +}); +Response response = await client.CreateConversationAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); +]]> +This sample shows how to call CreateConversationAsync with all request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + messages = new object[] + { + new + { + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + annotations = new object[] + { + new + { + type = "", + ToolCallId = "", + jsonPath = "", + url = "", + start = 1234, + end = 1234, + } + }, + } + }, + userId = "", + agentId = "", + agentRunId = "", + authorName = "", + createdAt = 1234L, + completedAt = 1234L, + } + }, +}); +Response response = await client.CreateConversationAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("completedAt").ToString()); +]]> + + + +This sample shows how to call CreateConversation and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + messages = new object[] + { + new + { + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + } + }, + } + }, +}); +Response response = client.CreateConversation(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); +]]> +This sample shows how to call CreateConversation with all request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + messages = new object[] + { + new + { + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + annotations = new object[] + { + new + { + type = "", + ToolCallId = "", + jsonPath = "", + url = "", + start = 1234, + end = 1234, + } + }, + } + }, + userId = "", + agentId = "", + agentRunId = "", + authorName = "", + createdAt = 1234L, + completedAt = 1234L, + } + }, +}); +Response response = client.CreateConversation(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("completedAt").ToString()); +]]> + + + +This sample shows how to call GetConversationAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetConversationAsync(""); +]]> +This sample shows how to call GetConversationAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetConversationAsync(""); +]]> + + + +This sample shows how to call GetConversation. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetConversation(""); +]]> +This sample shows how to call GetConversation with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetConversation(""); +]]> + + + +This sample shows how to call GetConversationAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetConversationAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); +]]> +This sample shows how to call GetConversationAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetConversationAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("completedAt").ToString()); +]]> + + + +This sample shows how to call GetConversation and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetConversation("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); +]]> +This sample shows how to call GetConversation with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetConversation("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("completedAt").ToString()); +]]> + + + +This sample shows how to call UpdateConversationAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Conversation body = new Conversation(new ChatMessage[] +{ + new UserMessage(new AIContent[] + { + new TextContent("") + }) +}); +Response response = await client.UpdateConversationAsync("", body); +]]> +This sample shows how to call UpdateConversationAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Conversation body = new Conversation(new ChatMessage[] +{ + new UserMessage(new AIContent[] + { + new TextContent("") + { + Annotations = {new Annotations("") + { + ToolCallId = "", + JsonPath = "", + Url = "", + Start = 1234, + End = 1234, + }}, + } + }) + { + UserId = "", + AgentId = "", + AgentRunId = "", + AuthorName = "", + CreatedAt = 1234L, + CompletedAt = 1234L, + } +}); +Response response = await client.UpdateConversationAsync("", body); +]]> + + + +This sample shows how to call UpdateConversation. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Conversation body = new Conversation(new ChatMessage[] +{ + new UserMessage(new AIContent[] + { + new TextContent("") + }) +}); +Response response = client.UpdateConversation("", body); +]]> +This sample shows how to call UpdateConversation with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Conversation body = new Conversation(new ChatMessage[] +{ + new UserMessage(new AIContent[] + { + new TextContent("") + { + Annotations = {new Annotations("") + { + ToolCallId = "", + JsonPath = "", + Url = "", + Start = 1234, + End = 1234, + }}, + } + }) + { + UserId = "", + AgentId = "", + AgentRunId = "", + AuthorName = "", + CreatedAt = 1234L, + CompletedAt = 1234L, + } +}); +Response response = client.UpdateConversation("", body); +]]> + + + +This sample shows how to call UpdateConversationAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + messages = new object[] + { + new + { + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + } + }, + } + }, +}); +Response response = await client.UpdateConversationAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); +]]> +This sample shows how to call UpdateConversationAsync with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + messages = new object[] + { + new + { + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + annotations = new object[] + { + new + { + type = "", + ToolCallId = "", + jsonPath = "", + url = "", + start = 1234, + end = 1234, + } + }, + } + }, + userId = "", + agentId = "", + agentRunId = "", + authorName = "", + createdAt = 1234L, + completedAt = 1234L, + } + }, +}); +Response response = await client.UpdateConversationAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("completedAt").ToString()); +]]> + + + +This sample shows how to call UpdateConversation and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + messages = new object[] + { + new + { + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + } + }, + } + }, +}); +Response response = client.UpdateConversation("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); +]]> +This sample shows how to call UpdateConversation with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + messages = new object[] + { + new + { + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + annotations = new object[] + { + new + { + type = "", + ToolCallId = "", + jsonPath = "", + url = "", + start = 1234, + end = 1234, + } + }, + } + }, + userId = "", + agentId = "", + agentRunId = "", + authorName = "", + createdAt = 1234L, + completedAt = 1234L, + } + }, +}); +Response response = client.UpdateConversation("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("messages")[0].GetProperty("completedAt").ToString()); +]]> + + + +This sample shows how to call DeleteConversationAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.DeleteConversationAsync(""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteConversationAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.DeleteConversationAsync(""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call DeleteConversation. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.DeleteConversation(""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteConversation with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.DeleteConversation(""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call GetConversationsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response> response = await client.GetConversationsAsync(); +]]> +This sample shows how to call GetConversationsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response> response = await client.GetConversationsAsync(); +]]> + + + +This sample shows how to call GetConversations. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response> response = client.GetConversations(); +]]> +This sample shows how to call GetConversations with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response> response = client.GetConversations(); +]]> + + + +This sample shows how to call GetConversationsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetConversationsAsync(null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("role").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); +]]> +This sample shows how to call GetConversationsAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetConversationsAsync(null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("userId").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("agentId").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("agentRunId").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("role").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("authorName").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("createdAt").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("completedAt").ToString()); +]]> + + + +This sample shows how to call GetConversations and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetConversations(null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("role").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); +]]> +This sample shows how to call GetConversations with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetConversations(null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("userId").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("agentId").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("messageId").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("agentRunId").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("conversationId").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("role").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("authorName").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("createdAt").ToString()); +Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("completedAt").ToString()); +]]> + + + \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Datasets.xml b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Datasets.xml new file mode 100644 index 000000000000..32153a945207 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Datasets.xml @@ -0,0 +1,1017 @@ + + + + + +This sample shows how to call GetVersionAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetVersionAsync("", ""); +]]> +This sample shows how to call GetVersionAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetVersionAsync("", ""); +]]> + + + +This sample shows how to call GetVersion. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetVersion("", ""); +]]> +This sample shows how to call GetVersion with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetVersion("", ""); +]]> + + + +This sample shows how to call GetVersionAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetVersionAsync("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("datasetUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call GetVersionAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetVersionAsync("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("datasetUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("isReference").ToString()); +Console.WriteLine(result.GetProperty("stage").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call GetVersion and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetVersion("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("datasetUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call GetVersion with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetVersion("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("datasetUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("isReference").ToString()); +Console.WriteLine(result.GetProperty("stage").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call DeleteVersionAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.DeleteVersionAsync("", ""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteVersionAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.DeleteVersionAsync("", ""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call DeleteVersion. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.DeleteVersion("", ""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteVersion with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.DeleteVersion("", ""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call CreateAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +DatasetVersion body = new FileDatasetVersion("", ""); +Response response = await client.CreateAsync("", body); +]]> +This sample shows how to call CreateAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +DatasetVersion body = new FileDatasetVersion("", "") +{ + Stage = "", + Description = "", + Tags = + { + ["key"] = "" + }, +}; +Response response = await client.CreateAsync("", body); +]]> + + + +This sample shows how to call Create. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +DatasetVersion body = new FileDatasetVersion("", ""); +Response response = client.Create("", body); +]]> +This sample shows how to call Create with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +DatasetVersion body = new FileDatasetVersion("", "") +{ + Stage = "", + Description = "", + Tags = + { + ["key"] = "" + }, +}; +Response response = client.Create("", body); +]]> + + + +This sample shows how to call CreateAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "uri_file", + openAIPurpose = "", + datasetUri = "", +}); +Response response = await client.CreateAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("datasetUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call CreateAsync with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "uri_file", + openAIPurpose = "", + datasetUri = "", + stage = "", + description = "", + tags = new + { + key = "", + }, +}); +Response response = await client.CreateAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("datasetUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("isReference").ToString()); +Console.WriteLine(result.GetProperty("stage").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call Create and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "uri_file", + openAIPurpose = "", + datasetUri = "", +}); +Response response = client.Create("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("datasetUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call Create with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "uri_file", + openAIPurpose = "", + datasetUri = "", + stage = "", + description = "", + tags = new + { + key = "", + }, +}); +Response response = client.Create("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("datasetUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("isReference").ToString()); +Console.WriteLine(result.GetProperty("stage").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call CreateVersionAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +DatasetVersion body = new FileDatasetVersion("", ""); +Response response = await client.CreateVersionAsync("", "", body); +]]> +This sample shows how to call CreateVersionAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +DatasetVersion body = new FileDatasetVersion("", "") +{ + Stage = "", + Description = "", + Tags = + { + ["key"] = "" + }, +}; +Response response = await client.CreateVersionAsync("", "", body); +]]> + + + +This sample shows how to call CreateVersion. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +DatasetVersion body = new FileDatasetVersion("", ""); +Response response = client.CreateVersion("", "", body); +]]> +This sample shows how to call CreateVersion with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +DatasetVersion body = new FileDatasetVersion("", "") +{ + Stage = "", + Description = "", + Tags = + { + ["key"] = "" + }, +}; +Response response = client.CreateVersion("", "", body); +]]> + + + +This sample shows how to call CreateVersionAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "uri_file", + openAIPurpose = "", + datasetUri = "", +}); +Response response = await client.CreateVersionAsync("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("datasetUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call CreateVersionAsync with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "uri_file", + openAIPurpose = "", + datasetUri = "", + stage = "", + description = "", + tags = new + { + key = "", + }, +}); +Response response = await client.CreateVersionAsync("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("datasetUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("isReference").ToString()); +Console.WriteLine(result.GetProperty("stage").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call CreateVersion and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "uri_file", + openAIPurpose = "", + datasetUri = "", +}); +Response response = client.CreateVersion("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("datasetUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call CreateVersion with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "uri_file", + openAIPurpose = "", + datasetUri = "", + stage = "", + description = "", + tags = new + { + key = "", + }, +}); +Response response = client.CreateVersion("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("datasetUri").ToString()); +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("isReference").ToString()); +Console.WriteLine(result.GetProperty("stage").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call StartPendingUploadAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +PendingUploadRequest body = new PendingUploadRequest(); +Response response = await client.StartPendingUploadAsync("", "", body); +]]> +This sample shows how to call StartPendingUploadAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +PendingUploadRequest body = new PendingUploadRequest +{ + PendingUploadId = "", + ConnectionName = "", +}; +Response response = await client.StartPendingUploadAsync("", "", body); +]]> + + + +This sample shows how to call StartPendingUpload. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +PendingUploadRequest body = new PendingUploadRequest(); +Response response = client.StartPendingUpload("", "", body); +]]> +This sample shows how to call StartPendingUpload with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +PendingUploadRequest body = new PendingUploadRequest +{ + PendingUploadId = "", + ConnectionName = "", +}; +Response response = client.StartPendingUpload("", "", body); +]]> + + + +This sample shows how to call StartPendingUploadAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + pendingUploadType = "TemporaryBlobReference", +}); +Response response = await client.StartPendingUploadAsync("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("blobUri").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("storageAccountArmId").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("sasToken").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); +]]> +This sample shows how to call StartPendingUploadAsync with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + pendingUploadId = "", + connectionName = "", + pendingUploadType = "TemporaryBlobReference", +}); +Response response = await client.StartPendingUploadAsync("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("blobUri").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("storageAccountArmId").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("sasToken").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); +Console.WriteLine(result.GetProperty("datasetVersion").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); +]]> + + + +This sample shows how to call StartPendingUpload and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + pendingUploadType = "TemporaryBlobReference", +}); +Response response = client.StartPendingUpload("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("blobUri").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("storageAccountArmId").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("sasToken").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); +]]> +This sample shows how to call StartPendingUpload with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + pendingUploadId = "", + connectionName = "", + pendingUploadType = "TemporaryBlobReference", +}); +Response response = client.StartPendingUpload("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("blobUri").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("storageAccountArmId").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("sasToken").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); +Console.WriteLine(result.GetProperty("datasetVersion").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); +]]> + + + +This sample shows how to call StartPendingUploadAutoIncrementAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.StartPendingUploadAutoIncrementAsync("", PendingUploadType.TemporaryBlobReference); +]]> +This sample shows how to call StartPendingUploadAutoIncrementAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.StartPendingUploadAutoIncrementAsync("", PendingUploadType.TemporaryBlobReference, pendingUploadId: "", connectionName: ""); +]]> + + + +This sample shows how to call StartPendingUploadAutoIncrement. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.StartPendingUploadAutoIncrement("", PendingUploadType.TemporaryBlobReference); +]]> +This sample shows how to call StartPendingUploadAutoIncrement with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.StartPendingUploadAutoIncrement("", PendingUploadType.TemporaryBlobReference, pendingUploadId: "", connectionName: ""); +]]> + + + +This sample shows how to call StartPendingUploadAutoIncrementAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + pendingUploadType = "TemporaryBlobReference", +}); +Response response = await client.StartPendingUploadAutoIncrementAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("blobUri").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("storageAccountArmId").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("sasToken").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); +]]> +This sample shows how to call StartPendingUploadAutoIncrementAsync with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + pendingUploadId = "", + connectionName = "", + pendingUploadType = "TemporaryBlobReference", +}); +Response response = await client.StartPendingUploadAutoIncrementAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("blobUri").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("storageAccountArmId").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("sasToken").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); +Console.WriteLine(result.GetProperty("datasetVersion").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); +]]> + + + +This sample shows how to call StartPendingUploadAutoIncrement and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + pendingUploadType = "TemporaryBlobReference", +}); +Response response = client.StartPendingUploadAutoIncrement("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("blobUri").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("storageAccountArmId").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("sasToken").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); +]]> +This sample shows how to call StartPendingUploadAutoIncrement with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + pendingUploadId = "", + connectionName = "", + pendingUploadType = "TemporaryBlobReference", +}); +Response response = client.StartPendingUploadAutoIncrement("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("blobUri").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("storageAccountArmId").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("sasToken").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); +Console.WriteLine(result.GetProperty("datasetVersion").ToString()); +Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); +]]> + + + +This sample shows how to call GetVersionsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +await foreach (DatasetVersion item in client.GetVersionsAsync("")) +{ +} +]]> +This sample shows how to call GetVersionsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +await foreach (DatasetVersion item in client.GetVersionsAsync("", maxCount: 1234, skip: "", tags: "", listViewType: ListViewType.ActiveOnly)) +{ +} +]]> + + + +This sample shows how to call GetVersions. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +foreach (DatasetVersion item in client.GetVersions("")) +{ +} +]]> +This sample shows how to call GetVersions with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +foreach (DatasetVersion item in client.GetVersions("", maxCount: 1234, skip: "", tags: "", listViewType: ListViewType.ActiveOnly)) +{ +} +]]> + + + +This sample shows how to call GetVersionsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +await foreach (BinaryData item in client.GetVersionsAsync("", null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); +} +]]> +This sample shows how to call GetVersionsAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +await foreach (BinaryData item in client.GetVersionsAsync("", 1234, "", "", "ActiveOnly", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +} +]]> + + + +This sample shows how to call GetVersions and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +foreach (BinaryData item in client.GetVersions("", null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); +} +]]> +This sample shows how to call GetVersions with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +foreach (BinaryData item in client.GetVersions("", 1234, "", "", "ActiveOnly", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +} +]]> + + + +This sample shows how to call GetLatestsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +await foreach (DatasetVersion item in client.GetLatestsAsync()) +{ +} +]]> +This sample shows how to call GetLatestsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +await foreach (DatasetVersion item in client.GetLatestsAsync(maxCount: 1234, skip: "", tags: "", listViewType: ListViewType.ActiveOnly)) +{ +} +]]> + + + +This sample shows how to call GetLatests. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +foreach (DatasetVersion item in client.GetLatests()) +{ +} +]]> +This sample shows how to call GetLatests with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +foreach (DatasetVersion item in client.GetLatests(maxCount: 1234, skip: "", tags: "", listViewType: ListViewType.ActiveOnly)) +{ +} +]]> + + + +This sample shows how to call GetLatestsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +await foreach (BinaryData item in client.GetLatestsAsync(null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); +} +]]> +This sample shows how to call GetLatestsAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +await foreach (BinaryData item in client.GetLatestsAsync(1234, "", "", "ActiveOnly", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +} +]]> + + + +This sample shows how to call GetLatests and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +foreach (BinaryData item in client.GetLatests(null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); +} +]]> +This sample shows how to call GetLatests with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + +foreach (BinaryData item in client.GetLatests(1234, "", "", "ActiveOnly", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Deployments.xml b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Deployments.xml new file mode 100644 index 000000000000..4658ca2969ba --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Deployments.xml @@ -0,0 +1,201 @@ + + + + + +This sample shows how to call GetDeploymentAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetDeploymentAsync(""); +]]> +This sample shows how to call GetDeploymentAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetDeploymentAsync(""); +]]> + + + +This sample shows how to call GetDeployment. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetDeployment(""); +]]> +This sample shows how to call GetDeployment with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetDeployment(""); +]]> + + + +This sample shows how to call GetDeploymentAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetDeploymentAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +]]> +This sample shows how to call GetDeploymentAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetDeploymentAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +]]> + + + +This sample shows how to call GetDeployment and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetDeployment("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +]]> +This sample shows how to call GetDeployment with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetDeployment("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +]]> + + + +This sample shows how to call GetDeploymentsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + +await foreach (Deployment item in client.GetDeploymentsAsync()) +{ +} +]]> +This sample shows how to call GetDeploymentsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + +await foreach (Deployment item in client.GetDeploymentsAsync(modelPublisher: "", modelName: "", includeConnectionModels: true, maxCount: 1234, skip: 1234, maxpagesize: 1234)) +{ +} +]]> + + + +This sample shows how to call GetDeployments. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + +foreach (Deployment item in client.GetDeployments()) +{ +} +]]> +This sample shows how to call GetDeployments with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + +foreach (Deployment item in client.GetDeployments(modelPublisher: "", modelName: "", includeConnectionModels: true, maxCount: 1234, skip: 1234, maxpagesize: 1234)) +{ +} +]]> + + + +This sample shows how to call GetDeploymentsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + +await foreach (BinaryData item in client.GetDeploymentsAsync(null, null, null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); +} +]]> +This sample shows how to call GetDeploymentsAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + +await foreach (BinaryData item in client.GetDeploymentsAsync("", "", true, 1234, 1234, 1234, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); +} +]]> + + + +This sample shows how to call GetDeployments and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + +foreach (BinaryData item in client.GetDeployments(null, null, null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); +} +]]> +This sample shows how to call GetDeployments with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + +foreach (BinaryData item in client.GetDeployments("", "", true, 1234, 1234, 1234, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Evaluations.xml b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Evaluations.xml new file mode 100644 index 000000000000..78a996af6ab2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Evaluations.xml @@ -0,0 +1,503 @@ + + + + + +This sample shows how to call GetEvaluationAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetEvaluationAsync(""); +]]> +This sample shows how to call GetEvaluationAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetEvaluationAsync(""); +]]> + + + +This sample shows how to call GetEvaluation. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetEvaluation(""); +]]> +This sample shows how to call GetEvaluation with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetEvaluation(""); +]]> + + + +This sample shows how to call GetEvaluationAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetEvaluationAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); +]]> +This sample shows how to call GetEvaluationAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetEvaluationAsync("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("initParams").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("dataMapping").GetProperty("").ToString()); +]]> + + + +This sample shows how to call GetEvaluation and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetEvaluation("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); +]]> +This sample shows how to call GetEvaluation with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetEvaluation("", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("initParams").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("dataMapping").GetProperty("").ToString()); +]]> + + + +This sample shows how to call CreateRunAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +Evaluation evaluation = new Evaluation(new InputDataset(""), new Dictionary +{ + ["key"] = new EvaluatorConfiguration("") +}); +Response response = await client.CreateRunAsync(evaluation); +]]> +This sample shows how to call CreateRunAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +Evaluation evaluation = new Evaluation(new InputDataset(""), new Dictionary +{ + ["key"] = new EvaluatorConfiguration("") + { + InitParams = + { + ["key"] = BinaryData.FromObjectAsJson(new object()) + }, + DataMapping = + { + ["key"] = "" + }, + } +}) +{ + DisplayName = "", + Description = "", + Tags = + { + ["key"] = "" + }, + Properties = + { + ["key"] = "" + }, +}; +Response response = await client.CreateRunAsync(evaluation); +]]> + + + +This sample shows how to call CreateRun. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +Evaluation evaluation = new Evaluation(new InputDataset(""), new Dictionary +{ + ["key"] = new EvaluatorConfiguration("") +}); +Response response = client.CreateRun(evaluation); +]]> +This sample shows how to call CreateRun with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +Evaluation evaluation = new Evaluation(new InputDataset(""), new Dictionary +{ + ["key"] = new EvaluatorConfiguration("") + { + InitParams = + { + ["key"] = BinaryData.FromObjectAsJson(new object()) + }, + DataMapping = + { + ["key"] = "" + }, + } +}) +{ + DisplayName = "", + Description = "", + Tags = + { + ["key"] = "" + }, + Properties = + { + ["key"] = "" + }, +}; +Response response = client.CreateRun(evaluation); +]]> + + + +This sample shows how to call CreateRunAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + data = new + { + type = "dataset", + id = "", + }, + evaluators = new + { + key = new + { + id = "", + }, + }, +}); +Response response = await client.CreateRunAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); +]]> +This sample shows how to call CreateRunAsync with all request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + data = new + { + type = "dataset", + id = "", + }, + displayName = "", + description = "", + tags = new + { + key = "", + }, + properties = new + { + key = "", + }, + evaluators = new + { + key = new + { + id = "", + initParams = new + { + key = new object(), + }, + dataMapping = new + { + key = "", + }, + }, + }, +}); +Response response = await client.CreateRunAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("initParams").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("dataMapping").GetProperty("").ToString()); +]]> + + + +This sample shows how to call CreateRun and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + data = new + { + type = "dataset", + id = "", + }, + evaluators = new + { + key = new + { + id = "", + }, + }, +}); +Response response = client.CreateRun(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); +]]> +This sample shows how to call CreateRun with all request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + data = new + { + type = "dataset", + id = "", + }, + displayName = "", + description = "", + tags = new + { + key = "", + }, + properties = new + { + key = "", + }, + evaluators = new + { + key = new + { + id = "", + initParams = new + { + key = new object(), + }, + dataMapping = new + { + key = "", + }, + }, + }, +}); +Response response = client.CreateRun(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("displayName").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("status").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("properties").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("initParams").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("dataMapping").GetProperty("").ToString()); +]]> + + + +This sample shows how to call GetEvaluationsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +await foreach (Evaluation item in client.GetEvaluationsAsync()) +{ +} +]]> +This sample shows how to call GetEvaluationsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +await foreach (Evaluation item in client.GetEvaluationsAsync(maxCount: 1234, skip: 1234, maxpagesize: 1234)) +{ +} +]]> + + + +This sample shows how to call GetEvaluations. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +foreach (Evaluation item in client.GetEvaluations()) +{ +} +]]> +This sample shows how to call GetEvaluations with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +foreach (Evaluation item in client.GetEvaluations(maxCount: 1234, skip: 1234, maxpagesize: 1234)) +{ +} +]]> + + + +This sample shows how to call GetEvaluationsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +await foreach (BinaryData item in client.GetEvaluationsAsync(null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); +} +]]> +This sample shows how to call GetEvaluationsAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +await foreach (BinaryData item in client.GetEvaluationsAsync(1234, 1234, 1234, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("initParams").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("dataMapping").GetProperty("").ToString()); +} +]]> + + + +This sample shows how to call GetEvaluations and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +foreach (BinaryData item in client.GetEvaluations(null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); +} +]]> +This sample shows how to call GetEvaluations with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + +foreach (BinaryData item in client.GetEvaluations(1234, 1234, 1234, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("initParams").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("dataMapping").GetProperty("").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Indexes.xml b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Indexes.xml new file mode 100644 index 000000000000..5a7b4de0ad83 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Indexes.xml @@ -0,0 +1,707 @@ + + + + + +This sample shows how to call GetVersionAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetVersionAsync("", ""); +]]> +This sample shows how to call GetVersionAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetVersionAsync("", ""); +]]> + + + +This sample shows how to call GetVersion. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetVersion("", ""); +]]> +This sample shows how to call GetVersion with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetVersion("", ""); +]]> + + + +This sample shows how to call GetVersionAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetVersionAsync("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call GetVersionAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetVersionAsync("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("stage").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call GetVersion and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetVersion("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call GetVersion with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetVersion("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("stage").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call DeleteVersionAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.DeleteVersionAsync("", ""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteVersionAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.DeleteVersionAsync("", ""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call DeleteVersion. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Response response = client.DeleteVersion("", ""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteVersion with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Response response = client.DeleteVersion("", ""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call CreateAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Index body = new AzureAISearchIndex("", ""); +Response response = await client.CreateAsync("", body); +]]> +This sample shows how to call CreateAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Index body = new AzureAISearchIndex("", "") +{ + Stage = "", + Description = "", + Tags = + { + ["key"] = "" + }, +}; +Response response = await client.CreateAsync("", body); +]]> + + + +This sample shows how to call Create. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Index body = new AzureAISearchIndex("", ""); +Response response = client.Create("", body); +]]> +This sample shows how to call Create with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Index body = new AzureAISearchIndex("", "") +{ + Stage = "", + Description = "", + Tags = + { + ["key"] = "" + }, +}; +Response response = client.Create("", body); +]]> + + + +This sample shows how to call CreateAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "AzureSearch", + connectionName = "", + indexName = "", +}); +Response response = await client.CreateAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call CreateAsync with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "AzureSearch", + connectionName = "", + indexName = "", + stage = "", + description = "", + tags = new + { + key = "", + }, +}); +Response response = await client.CreateAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("stage").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call Create and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "AzureSearch", + connectionName = "", + indexName = "", +}); +Response response = client.Create("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call Create with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "AzureSearch", + connectionName = "", + indexName = "", + stage = "", + description = "", + tags = new + { + key = "", + }, +}); +Response response = client.Create("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("stage").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call CreateVersionAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Index body = new AzureAISearchIndex("", ""); +Response response = await client.CreateVersionAsync("", "", body); +]]> +This sample shows how to call CreateVersionAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Index body = new AzureAISearchIndex("", "") +{ + Stage = "", + Description = "", + Tags = + { + ["key"] = "" + }, +}; +Response response = await client.CreateVersionAsync("", "", body); +]]> + + + +This sample shows how to call CreateVersion. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Index body = new AzureAISearchIndex("", ""); +Response response = client.CreateVersion("", "", body); +]]> +This sample shows how to call CreateVersion with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +Index body = new AzureAISearchIndex("", "") +{ + Stage = "", + Description = "", + Tags = + { + ["key"] = "" + }, +}; +Response response = client.CreateVersion("", "", body); +]]> + + + +This sample shows how to call CreateVersionAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "AzureSearch", + connectionName = "", + indexName = "", +}); +Response response = await client.CreateVersionAsync("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call CreateVersionAsync with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "AzureSearch", + connectionName = "", + indexName = "", + stage = "", + description = "", + tags = new + { + key = "", + }, +}); +Response response = await client.CreateVersionAsync("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("stage").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call CreateVersion and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "AzureSearch", + connectionName = "", + indexName = "", +}); +Response response = client.CreateVersion("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +]]> +This sample shows how to call CreateVersion with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + type = "AzureSearch", + connectionName = "", + indexName = "", + stage = "", + description = "", + tags = new + { + key = "", + }, +}); +Response response = client.CreateVersion("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("stage").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("version").ToString()); +Console.WriteLine(result.GetProperty("description").ToString()); +Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +]]> + + + +This sample shows how to call GetVersionsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +await foreach (Index item in client.GetVersionsAsync("")) +{ +} +]]> +This sample shows how to call GetVersionsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +await foreach (Index item in client.GetVersionsAsync("", maxCount: 1234, skip: "", tags: "", listViewType: ListViewType.ActiveOnly)) +{ +} +]]> + + + +This sample shows how to call GetVersions. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +foreach (Index item in client.GetVersions("")) +{ +} +]]> +This sample shows how to call GetVersions with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +foreach (Index item in client.GetVersions("", maxCount: 1234, skip: "", tags: "", listViewType: ListViewType.ActiveOnly)) +{ +} +]]> + + + +This sample shows how to call GetVersionsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +await foreach (BinaryData item in client.GetVersionsAsync("", null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); +} +]]> +This sample shows how to call GetVersionsAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +await foreach (BinaryData item in client.GetVersionsAsync("", 1234, "", "", "ActiveOnly", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +} +]]> + + + +This sample shows how to call GetVersions and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +foreach (BinaryData item in client.GetVersions("", null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); +} +]]> +This sample shows how to call GetVersions with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +foreach (BinaryData item in client.GetVersions("", 1234, "", "", "ActiveOnly", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +} +]]> + + + +This sample shows how to call GetLatestsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +await foreach (Index item in client.GetLatestsAsync()) +{ +} +]]> +This sample shows how to call GetLatestsAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +await foreach (Index item in client.GetLatestsAsync(maxCount: 1234, skip: "", tags: "", listViewType: ListViewType.ActiveOnly)) +{ +} +]]> + + + +This sample shows how to call GetLatests. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +foreach (Index item in client.GetLatests()) +{ +} +]]> +This sample shows how to call GetLatests with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +foreach (Index item in client.GetLatests(maxCount: 1234, skip: "", tags: "", listViewType: ListViewType.ActiveOnly)) +{ +} +]]> + + + +This sample shows how to call GetLatestsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +await foreach (BinaryData item in client.GetLatestsAsync(null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); +} +]]> +This sample shows how to call GetLatestsAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +await foreach (BinaryData item in client.GetLatestsAsync(1234, "", "", "ActiveOnly", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +} +]]> + + + +This sample shows how to call GetLatests and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +foreach (BinaryData item in client.GetLatests(null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); +} +]]> +This sample shows how to call GetLatests with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + +foreach (BinaryData item in client.GetLatests(1234, "", "", "ActiveOnly", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Messages.xml b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Messages.xml new file mode 100644 index 000000000000..20efd1dc0402 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Docs/Messages.xml @@ -0,0 +1,783 @@ + + + + + +This sample shows how to call SendMessageAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +ChatMessage body = new UserMessage(new AIContent[] +{ + new TextContent("") +}); +Response response = await client.SendMessageAsync("", body); +]]> +This sample shows how to call SendMessageAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +ChatMessage body = new UserMessage(new AIContent[] +{ + new TextContent("") + { + Annotations = {new Annotations("") + { + ToolCallId = "", + JsonPath = "", + Url = "", + Start = 1234, + End = 1234, + }}, + } +}) +{ + UserId = "", + AgentId = "", + AgentRunId = "", + AuthorName = "", + CreatedAt = 1234L, + CompletedAt = 1234L, +}; +Response response = await client.SendMessageAsync("", body); +]]> + + + +This sample shows how to call SendMessage. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +ChatMessage body = new UserMessage(new AIContent[] +{ + new TextContent("") +}); +Response response = client.SendMessage("", body); +]]> +This sample shows how to call SendMessage with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +ChatMessage body = new UserMessage(new AIContent[] +{ + new TextContent("") + { + Annotations = {new Annotations("") + { + ToolCallId = "", + JsonPath = "", + Url = "", + Start = 1234, + End = 1234, + }}, + } +}) +{ + UserId = "", + AgentId = "", + AgentRunId = "", + AuthorName = "", + CreatedAt = 1234L, + CompletedAt = 1234L, +}; +Response response = client.SendMessage("", body); +]]> + + + +This sample shows how to call SendMessageAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + } + }, +}); +Response response = await client.SendMessageAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); +]]> +This sample shows how to call SendMessageAsync with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + annotations = new object[] + { + new + { + type = "", + ToolCallId = "", + jsonPath = "", + url = "", + start = 1234, + end = 1234, + } + }, + } + }, + userId = "", + agentId = "", + agentRunId = "", + authorName = "", + createdAt = 1234L, + completedAt = 1234L, +}); +Response response = await client.SendMessageAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +]]> + + + +This sample shows how to call SendMessage and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + } + }, +}); +Response response = client.SendMessage("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); +]]> +This sample shows how to call SendMessage with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + annotations = new object[] + { + new + { + type = "", + ToolCallId = "", + jsonPath = "", + url = "", + start = 1234, + end = 1234, + } + }, + } + }, + userId = "", + agentId = "", + agentRunId = "", + authorName = "", + createdAt = 1234L, + completedAt = 1234L, +}); +Response response = client.SendMessage("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +]]> + + + +This sample shows how to call GetMessageAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetMessageAsync("", ""); +]]> +This sample shows how to call GetMessageAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetMessageAsync("", ""); +]]> + + + +This sample shows how to call GetMessage. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetMessage("", ""); +]]> +This sample shows how to call GetMessage with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetMessage("", ""); +]]> + + + +This sample shows how to call GetMessageAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetMessageAsync("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); +]]> +This sample shows how to call GetMessageAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.GetMessageAsync("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +]]> + + + +This sample shows how to call GetMessage and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetMessage("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); +]]> +This sample shows how to call GetMessage with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +Response response = client.GetMessage("", "", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +]]> + + + +This sample shows how to call UpdateMessageAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +ChatMessage resource = new UserMessage(new AIContent[] +{ + new TextContent("") +}); +Response response = await client.UpdateMessageAsync("", "", resource); +]]> +This sample shows how to call UpdateMessageAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +ChatMessage resource = new UserMessage(new AIContent[] +{ + new TextContent("") + { + Annotations = {new Annotations("") + { + ToolCallId = "", + JsonPath = "", + Url = "", + Start = 1234, + End = 1234, + }}, + } +}) +{ + UserId = "", + AgentId = "", + AgentRunId = "", + AuthorName = "", + CreatedAt = 1234L, + CompletedAt = 1234L, +}; +Response response = await client.UpdateMessageAsync("", "", resource); +]]> + + + +This sample shows how to call UpdateMessage. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +ChatMessage resource = new UserMessage(new AIContent[] +{ + new TextContent("") +}); +Response response = client.UpdateMessage("", "", resource); +]]> +This sample shows how to call UpdateMessage with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +ChatMessage resource = new UserMessage(new AIContent[] +{ + new TextContent("") + { + Annotations = {new Annotations("") + { + ToolCallId = "", + JsonPath = "", + Url = "", + Start = 1234, + End = 1234, + }}, + } +}) +{ + UserId = "", + AgentId = "", + AgentRunId = "", + AuthorName = "", + CreatedAt = 1234L, + CompletedAt = 1234L, +}; +Response response = client.UpdateMessage("", "", resource); +]]> + + + +This sample shows how to call UpdateMessageAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + } + }, +}); +Response response = await client.UpdateMessageAsync("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); +]]> +This sample shows how to call UpdateMessageAsync with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + annotations = new object[] + { + new + { + type = "", + ToolCallId = "", + jsonPath = "", + url = "", + start = 1234, + end = 1234, + } + }, + } + }, + userId = "", + agentId = "", + agentRunId = "", + authorName = "", + createdAt = 1234L, + completedAt = 1234L, +}); +Response response = await client.UpdateMessageAsync("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +]]> + + + +This sample shows how to call UpdateMessage and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + } + }, +}); +Response response = client.UpdateMessage("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); +]]> +This sample shows how to call UpdateMessage with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + role = "user", + content = new object[] + { + new + { + type = "text", + text = "", + annotations = new object[] + { + new + { + type = "", + ToolCallId = "", + jsonPath = "", + url = "", + start = 1234, + end = 1234, + } + }, + } + }, + userId = "", + agentId = "", + agentRunId = "", + authorName = "", + createdAt = 1234L, + completedAt = 1234L, +}); +Response response = client.UpdateMessage("", "", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("userId").ToString()); +Console.WriteLine(result.GetProperty("agentId").ToString()); +Console.WriteLine(result.GetProperty("messageId").ToString()); +Console.WriteLine(result.GetProperty("agentRunId").ToString()); +Console.WriteLine(result.GetProperty("conversationId").ToString()); +Console.WriteLine(result.GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("authorName").ToString()); +Console.WriteLine(result.GetProperty("createdAt").ToString()); +Console.WriteLine(result.GetProperty("completedAt").ToString()); +]]> + + + +This sample shows how to call DeleteMessageAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.DeleteMessageAsync("", ""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteMessageAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +Response response = await client.DeleteMessageAsync("", ""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call DeleteMessage. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +Response response = client.DeleteMessage("", ""); + +Console.WriteLine(response.Status); +]]> +This sample shows how to call DeleteMessage with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +Response response = client.DeleteMessage("", ""); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call GetMessagesAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +await foreach (ChatMessage item in client.GetMessagesAsync("")) +{ +} +]]> +This sample shows how to call GetMessagesAsync with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +await foreach (ChatMessage item in client.GetMessagesAsync("")) +{ +} +]]> + + + +This sample shows how to call GetMessages. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +foreach (ChatMessage item in client.GetMessages("")) +{ +} +]]> +This sample shows how to call GetMessages with all parameters. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +foreach (ChatMessage item in client.GetMessages("")) +{ +} +]]> + + + +This sample shows how to call GetMessagesAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +await foreach (BinaryData item in client.GetMessagesAsync("", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); +} +]]> +This sample shows how to call GetMessagesAsync with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +await foreach (BinaryData item in client.GetMessagesAsync("", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); +} +]]> + + + +This sample shows how to call GetMessages and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +foreach (BinaryData item in client.GetMessages("", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); +} +]]> +This sample shows how to call GetMessages with all parameters and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + +foreach (BinaryData item in client.GetMessages("", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/EmbeddingConfiguration.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/EmbeddingConfiguration.Serialization.cs new file mode 100644 index 000000000000..8ffb1362179c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/EmbeddingConfiguration.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.Projects.OneDP +{ + public partial class EmbeddingConfiguration : 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(EmbeddingConfiguration)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("modelDeploymentName"u8); + writer.WriteStringValue(ModelDeploymentName); + writer.WritePropertyName("embeddingField"u8); + writer.WriteStringValue(EmbeddingField); + 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 + } + } + } + + EmbeddingConfiguration 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(EmbeddingConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEmbeddingConfiguration(document.RootElement, options); + } + + internal static EmbeddingConfiguration DeserializeEmbeddingConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string modelDeploymentName = default; + string embeddingField = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("modelDeploymentName"u8)) + { + modelDeploymentName = property.Value.GetString(); + continue; + } + if (property.NameEquals("embeddingField"u8)) + { + embeddingField = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EmbeddingConfiguration(modelDeploymentName, embeddingField, 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(EmbeddingConfiguration)} does not support writing '{options.Format}' format."); + } + } + + EmbeddingConfiguration 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 DeserializeEmbeddingConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EmbeddingConfiguration)} 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 EmbeddingConfiguration FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEmbeddingConfiguration(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/ai/Azure.AI.Projects.OneDP/src/Generated/EmbeddingConfiguration.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/EmbeddingConfiguration.cs new file mode 100644 index 000000000000..b4c9213fda10 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/EmbeddingConfiguration.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.Projects.OneDP +{ + /// Embedding configuration class. + public partial class EmbeddingConfiguration + { + /// + /// 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 . + /// Deployment name of embedding model. It can point to a model deployment either in the parent AIServices or a connection. + /// Embedding field. + /// or is null. + public EmbeddingConfiguration(string modelDeploymentName, string embeddingField) + { + Argument.AssertNotNull(modelDeploymentName, nameof(modelDeploymentName)); + Argument.AssertNotNull(embeddingField, nameof(embeddingField)); + + ModelDeploymentName = modelDeploymentName; + EmbeddingField = embeddingField; + } + + /// Initializes a new instance of . + /// Deployment name of embedding model. It can point to a model deployment either in the parent AIServices or a connection. + /// Embedding field. + /// Keeps track of any properties unknown to the library. + internal EmbeddingConfiguration(string modelDeploymentName, string embeddingField, IDictionary serializedAdditionalRawData) + { + ModelDeploymentName = modelDeploymentName; + EmbeddingField = embeddingField; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal EmbeddingConfiguration() + { + } + + /// Deployment name of embedding model. It can point to a model deployment either in the parent AIServices or a connection. + public string ModelDeploymentName { get; set; } + /// Embedding field. + public string EmbeddingField { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Evaluation.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Evaluation.Serialization.cs new file mode 100644 index 000000000000..1503fd8624a0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Evaluation.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.Projects.OneDP +{ + public partial class Evaluation : 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(Evaluation)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + writer.WritePropertyName("data"u8); + writer.WriteObjectValue(Data, options); + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + foreach (var item in Properties) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("evaluators"u8); + writer.WriteStartObject(); + foreach (var item in Evaluators) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + 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 + } + } + } + + Evaluation 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(Evaluation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvaluation(document.RootElement, options); + } + + internal static Evaluation DeserializeEvaluation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + InputData data = default; + string displayName = default; + string description = default; + string status = default; + IDictionary tags = default; + IDictionary properties = default; + IDictionary evaluators = 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("data"u8)) + { + data = InputData.DeserializeInputData(property.Value, options); + continue; + } + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"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()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("properties"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()); + } + properties = dictionary; + continue; + } + if (property.NameEquals("evaluators"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, EvaluatorConfiguration.DeserializeEvaluatorConfiguration(property0.Value, options)); + } + evaluators = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Evaluation( + id, + data, + displayName, + description, + status, + tags ?? new ChangeTrackingDictionary(), + properties ?? new ChangeTrackingDictionary(), + evaluators, + 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(Evaluation)} does not support writing '{options.Format}' format."); + } + } + + Evaluation 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 DeserializeEvaluation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Evaluation)} 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 Evaluation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEvaluation(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/ai/Azure.AI.Projects.OneDP/src/Generated/Evaluation.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Evaluation.cs new file mode 100644 index 000000000000..c73c134620d1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Evaluation.cs @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Evaluation Definition. + public partial class Evaluation + { + /// + /// 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 . + /// + /// Data for evaluation. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + /// Evaluators to be used for the evaluation. + /// or is null. + public Evaluation(InputData data, IDictionary evaluators) + { + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(evaluators, nameof(evaluators)); + + Data = data; + Tags = new ChangeTrackingDictionary(); + Properties = new ChangeTrackingDictionary(); + Evaluators = evaluators; + } + + /// Initializes a new instance of . + /// Identifier of the evaluation. + /// + /// Data for evaluation. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + /// Display Name for evaluation. It helps to find the evaluation easily in AI Foundry. It does not need to be unique. + /// Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. + /// Status of the evaluation. It is set by service and is read-only. + /// Evaluation's tags. Unlike properties, tags are fully mutable. + /// Evaluation's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. + /// Evaluators to be used for the evaluation. + /// Keeps track of any properties unknown to the library. + internal Evaluation(string id, InputData data, string displayName, string description, string status, IDictionary tags, IDictionary properties, IDictionary evaluators, IDictionary serializedAdditionalRawData) + { + Id = id; + Data = data; + DisplayName = displayName; + Description = description; + Status = status; + Tags = tags; + Properties = properties; + Evaluators = evaluators; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Evaluation() + { + } + + /// Identifier of the evaluation. + public string Id { get; } + /// + /// Data for evaluation. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + public InputData Data { get; set; } + /// Display Name for evaluation. It helps to find the evaluation easily in AI Foundry. It does not need to be unique. + public string DisplayName { get; set; } + /// Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. + public string Description { get; set; } + /// Status of the evaluation. It is set by service and is read-only. + public string Status { get; } + /// Evaluation's tags. Unlike properties, tags are fully mutable. + public IDictionary Tags { get; } + /// Evaluation's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. + public IDictionary Properties { get; } + /// Evaluators to be used for the evaluation. + public IDictionary Evaluators { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Evaluations.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Evaluations.cs new file mode 100644 index 000000000000..70e480766272 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Evaluations.cs @@ -0,0 +1,446 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Projects.OneDP +{ + // Data plane generated sub-client. + /// The Evaluations sub-client. + public partial class Evaluations + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + 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 Evaluations for mocking. + protected Evaluations() + { + } + + /// Initializes a new instance of Evaluations. + /// 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. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// The API version to use for this operation. + internal Evaluations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Get an evaluation run by name. + /// Identifier of the evaluation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetEvaluationAsync(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetEvaluationAsync(name, context).ConfigureAwait(false); + return Response.FromValue(Evaluation.FromResponse(response), response); + } + + /// Get an evaluation run by name. + /// Identifier of the evaluation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetEvaluation(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetEvaluation(name, context); + return Response.FromValue(Evaluation.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get an evaluation run by name. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Identifier of the evaluation. + /// 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 GetEvaluationAsync(string name, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = ClientDiagnostics.CreateScope("Evaluations.GetEvaluation"); + scope.Start(); + try + { + using HttpMessage message = CreateGetEvaluationRequest(name, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get an evaluation run by name. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Identifier of the evaluation. + /// 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 GetEvaluation(string name, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = ClientDiagnostics.CreateScope("Evaluations.GetEvaluation"); + scope.Start(); + try + { + using HttpMessage message = CreateGetEvaluationRequest(name, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates an evaluation run. + /// Evaluation to be run. + /// The cancellation token to use. + /// is null. + /// + public virtual async Task> CreateRunAsync(Evaluation evaluation, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(evaluation, nameof(evaluation)); + + using RequestContent content = evaluation.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateRunAsync(content, context).ConfigureAwait(false); + return Response.FromValue(Evaluation.FromResponse(response), response); + } + + /// Creates an evaluation run. + /// Evaluation to be run. + /// The cancellation token to use. + /// is null. + /// + public virtual Response CreateRun(Evaluation evaluation, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(evaluation, nameof(evaluation)); + + using RequestContent content = evaluation.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CreateRun(content, context); + return Response.FromValue(Evaluation.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates an evaluation run. + /// + /// + /// + /// 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 CreateRunAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Evaluations.CreateRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateRunRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates an evaluation run. + /// + /// + /// + /// 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 CreateRun(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Evaluations.CreateRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateRunRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List evaluation runs. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// + public virtual AsyncPageable GetEvaluationsAsync(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) => CreateGetEvaluationsRequest(maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetEvaluationsNextPageRequest(nextLink, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Evaluation.DeserializeEvaluation(e), ClientDiagnostics, _pipeline, "Evaluations.GetEvaluations", "value", "nextLink", maxpagesize, context); + } + + /// List evaluation runs. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// + public virtual Pageable GetEvaluations(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) => CreateGetEvaluationsRequest(maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetEvaluationsNextPageRequest(nextLink, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Evaluation.DeserializeEvaluation(e), ClientDiagnostics, _pipeline, "Evaluations.GetEvaluations", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] List evaluation runs + /// + /// + /// + /// 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 number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// 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 GetEvaluationsAsync(int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetEvaluationsRequest(maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetEvaluationsNextPageRequest(nextLink, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Evaluations.GetEvaluations", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] List evaluation runs + /// + /// + /// + /// 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 number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// 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 GetEvaluations(int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetEvaluationsRequest(maxCount, skip, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetEvaluationsNextPageRequest(nextLink, maxCount, skip, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Evaluations.GetEvaluations", "value", "nextLink", maxpagesize, context); + } + + internal HttpMessage CreateGetEvaluationRequest(string name, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/evaluations/runs/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetEvaluationsRequest(int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/evaluations/runs", 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 CreateCreateRunRequest(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.AppendPath("/evaluations/runs:run", 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; + } + + internal HttpMessage CreateGetEvaluationsNextPageRequest(string nextLink, int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + 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/ai/Azure.AI.Projects.OneDP/src/Generated/EvaluatorConfiguration.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/EvaluatorConfiguration.Serialization.cs new file mode 100644 index 000000000000..0affbc74f720 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/EvaluatorConfiguration.Serialization.cs @@ -0,0 +1,213 @@ +// 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.Projects.OneDP +{ + public partial class EvaluatorConfiguration : 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(EvaluatorConfiguration)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + if (Optional.IsCollectionDefined(InitParams)) + { + writer.WritePropertyName("initParams"u8); + writer.WriteStartObject(); + foreach (var item in InitParams) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#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 + } + writer.WriteEndObject(); + } + if (Optional.IsCollectionDefined(DataMapping)) + { + writer.WritePropertyName("dataMapping"u8); + writer.WriteStartObject(); + foreach (var item in DataMapping) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + 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 + } + } + } + + EvaluatorConfiguration 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(EvaluatorConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvaluatorConfiguration(document.RootElement, options); + } + + internal static EvaluatorConfiguration DeserializeEvaluatorConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + IDictionary initParams = default; + IDictionary dataMapping = 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("initParams"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + initParams = dictionary; + continue; + } + if (property.NameEquals("dataMapping"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()); + } + dataMapping = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EvaluatorConfiguration(id, initParams ?? new ChangeTrackingDictionary(), dataMapping ?? new ChangeTrackingDictionary(), 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(EvaluatorConfiguration)} does not support writing '{options.Format}' format."); + } + } + + EvaluatorConfiguration 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 DeserializeEvaluatorConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvaluatorConfiguration)} 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 EvaluatorConfiguration FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEvaluatorConfiguration(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/ai/Azure.AI.Projects.OneDP/src/Generated/EvaluatorConfiguration.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/EvaluatorConfiguration.cs new file mode 100644 index 000000000000..10492f8d1165 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/EvaluatorConfiguration.cs @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Evaluator Configuration. + public partial class EvaluatorConfiguration + { + /// + /// 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 . + /// Identifier of the evaluator. + /// is null. + public EvaluatorConfiguration(string id) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + InitParams = new ChangeTrackingDictionary(); + DataMapping = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Identifier of the evaluator. + /// Initialization parameters of the evaluator. + /// Data parameters of the evaluator. + /// Keeps track of any properties unknown to the library. + internal EvaluatorConfiguration(string id, IDictionary initParams, IDictionary dataMapping, IDictionary serializedAdditionalRawData) + { + Id = id; + InitParams = initParams; + DataMapping = dataMapping; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal EvaluatorConfiguration() + { + } + + /// Identifier of the evaluator. + public string Id { get; set; } + /// + /// Initialization parameters of the evaluator. + /// + /// 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" }. + /// + /// + /// + /// + public IDictionary InitParams { get; } + /// Data parameters of the evaluator. + public IDictionary DataMapping { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileContent.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileContent.Serialization.cs new file mode 100644 index 000000000000..c4cb6f08de8d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileContent.Serialization.cs @@ -0,0 +1,200 @@ +// 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.Projects.OneDP +{ + public partial class FileContent : 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 override 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(FileContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(FileName)) + { + writer.WritePropertyName("fileName"u8); + writer.WriteStringValue(FileName); + } + if (Optional.IsDefined(MimeType)) + { + writer.WritePropertyName("mimeType"u8); + writer.WriteStringValue(MimeType); + } + if (Optional.IsDefined(Uri)) + { + writer.WritePropertyName("uri"u8); + writer.WriteStringValue(Uri.AbsoluteUri); + } + if (Optional.IsDefined(DataUri)) + { + writer.WritePropertyName("dataUri"u8); + writer.WriteStringValue(DataUri.AbsoluteUri); + } + if (Optional.IsDefined(Data)) + { + writer.WritePropertyName("data"u8); + writer.WriteBase64StringValue(Data.ToArray(), "D"); + } + } + + FileContent 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(FileContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileContent(document.RootElement, options); + } + + internal static FileContent DeserializeFileContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileName = default; + string mimeType = default; + Uri uri = default; + Uri dataUri = default; + BinaryData data = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("fileName"u8)) + { + fileName = property.Value.GetString(); + continue; + } + if (property.NameEquals("mimeType"u8)) + { + mimeType = property.Value.GetString(); + continue; + } + if (property.NameEquals("uri"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + uri = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("dataUri"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataUri = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("data"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + data = BinaryData.FromBytes(property.Value.GetBytesFromBase64("D")); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FileContent( + type, + serializedAdditionalRawData, + fileName, + mimeType, + uri, + dataUri, + data); + } + + 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(FileContent)} does not support writing '{options.Format}' format."); + } + } + + FileContent 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 DeserializeFileContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileContent)} 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 new FileContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFileContent(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileContent.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileContent.cs new file mode 100644 index 000000000000..fae251374a6a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileContent.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.Projects.OneDP +{ + /// A structured chat content item containing a file data item. + public partial class FileContent : AIContent + { + /// Initializes a new instance of . + public FileContent() + { + Type = "file"; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The file name for this binary content. + /// The MIME type for this binary content. + /// URI where the binary content can be retrieved. + /// Data URI containing the binary content inlined. + /// Raw bytes for the binary content. + internal FileContent(string type, IDictionary serializedAdditionalRawData, string fileName, string mimeType, Uri uri, Uri dataUri, BinaryData data) : base(type, serializedAdditionalRawData) + { + FileName = fileName; + MimeType = mimeType; + Uri = uri; + DataUri = dataUri; + Data = data; + } + + /// The file name for this binary content. + public string FileName { get; set; } + /// The MIME type for this binary content. + public string MimeType { get; set; } + /// URI where the binary content can be retrieved. + public Uri Uri { get; set; } + /// Data URI containing the binary content inlined. + public Uri DataUri { get; set; } + /// + /// Raw bytes for the binary content. + /// + /// To assign a byte[] to this property use . + /// The byte[] will be serialized to a Base64 encoded string. + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromBytes(new byte[] { 1, 2, 3 }) + /// Creates a payload of "AQID". + /// + /// + /// + /// + public BinaryData Data { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileDatasetVersion.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileDatasetVersion.Serialization.cs new file mode 100644 index 000000000000..5b27cb377f79 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileDatasetVersion.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.Projects.OneDP +{ + public partial class FileDatasetVersion : 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 override 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(FileDatasetVersion)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("openAIPurpose"u8); + writer.WriteStringValue(OpenAIPurpose); + } + + FileDatasetVersion 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(FileDatasetVersion)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileDatasetVersion(document.RootElement, options); + } + + internal static FileDatasetVersion DeserializeFileDatasetVersion(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string openAIPurpose = default; + string datasetUri = default; + DatasetType type = default; + bool? isReference = default; + string stage = default; + string id = default; + string name = default; + string version = default; + string description = default; + IDictionary tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("openAIPurpose"u8)) + { + openAIPurpose = property.Value.GetString(); + continue; + } + if (property.NameEquals("datasetUri"u8)) + { + datasetUri = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new DatasetType(property.Value.GetString()); + continue; + } + if (property.NameEquals("isReference"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isReference = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("stage"u8)) + { + stage = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("version"u8)) + { + version = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"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()); + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FileDatasetVersion( + datasetUri, + type, + isReference, + stage, + id, + name, + version, + description, + tags ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData, + openAIPurpose); + } + + 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(FileDatasetVersion)} does not support writing '{options.Format}' format."); + } + } + + FileDatasetVersion 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 DeserializeFileDatasetVersion(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileDatasetVersion)} 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 new FileDatasetVersion FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFileDatasetVersion(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileDatasetVersion.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileDatasetVersion.cs new file mode 100644 index 000000000000..ed3cb63143fe --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileDatasetVersion.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// FileDatasetVersion Definition. + public partial class FileDatasetVersion : DatasetVersion + { + /// Initializes a new instance of . + /// [Required] Uri of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// Indicates OpenAI Purpose. FileDatasets created with this field will be compatible with OpenAI-specific features. + /// or is null. + public FileDatasetVersion(string datasetUri, string openAIPurpose) : base(datasetUri) + { + Argument.AssertNotNull(datasetUri, nameof(datasetUri)); + Argument.AssertNotNull(openAIPurpose, nameof(openAIPurpose)); + + Type = DatasetType.UriFile; + OpenAIPurpose = openAIPurpose; + } + + /// Initializes a new instance of . + /// [Required] Uri of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// Dataset type. + /// Indicates if dataset is reference only or managed by dataset service. If true, the underlying data will be deleted when the dataset version is deleted. + /// Asset stage. + /// A unique identifier for the asset, assetId probably?. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Keeps track of any properties unknown to the library. + /// Indicates OpenAI Purpose. FileDatasets created with this field will be compatible with OpenAI-specific features. + internal FileDatasetVersion(string datasetUri, DatasetType type, bool? isReference, string stage, string id, string name, string version, string description, IDictionary tags, IDictionary serializedAdditionalRawData, string openAIPurpose) : base(datasetUri, type, isReference, stage, id, name, version, description, tags, serializedAdditionalRawData) + { + OpenAIPurpose = openAIPurpose; + } + + /// Initializes a new instance of for deserialization. + internal FileDatasetVersion() + { + } + + /// Indicates OpenAI Purpose. FileDatasets created with this field will be compatible with OpenAI-specific features. + public string OpenAIPurpose { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileSearchToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileSearchToolDefinition.Serialization.cs new file mode 100644 index 000000000000..ab3c1b485277 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileSearchToolDefinition.Serialization.cs @@ -0,0 +1,201 @@ +// 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.Projects.OneDP +{ + public partial class FileSearchToolDefinition : 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 override 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(FileSearchToolDefinition)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(MaxNumResults)) + { + writer.WritePropertyName("maxNumResults"u8); + writer.WriteNumberValue(MaxNumResults.Value); + } + if (Optional.IsDefined(RankingOptions)) + { + writer.WritePropertyName("rankingOptions"u8); + writer.WriteObjectValue(RankingOptions, options); + } + writer.WritePropertyName("fileIds"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + + FileSearchToolDefinition 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(FileSearchToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileSearchToolDefinition(document.RootElement, options); + } + + internal static FileSearchToolDefinition DeserializeFileSearchToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? maxNumResults = default; + FileSearchToolDefinitionRankingOptions rankingOptions = default; + IList fileIds = default; + string type = default; + AgentToolOptions options0 = default; + AgentToolDefinitionOverride @override = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("maxNumResults"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxNumResults = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("rankingOptions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + rankingOptions = FileSearchToolDefinitionRankingOptions.DeserializeFileSearchToolDefinitionRankingOptions(property.Value, options); + continue; + } + if (property.NameEquals("fileIds"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + fileIds = array; + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("options"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + options0 = AgentToolOptions.DeserializeAgentToolOptions(property.Value, options); + continue; + } + if (property.NameEquals("override"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + @override = AgentToolDefinitionOverride.DeserializeAgentToolDefinitionOverride(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FileSearchToolDefinition( + type, + options0, + @override, + serializedAdditionalRawData, + maxNumResults, + rankingOptions, + fileIds); + } + + 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(FileSearchToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + FileSearchToolDefinition 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 DeserializeFileSearchToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileSearchToolDefinition)} 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 new FileSearchToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFileSearchToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileSearchToolDefinition.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileSearchToolDefinition.cs new file mode 100644 index 000000000000..aace6dd98630 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileSearchToolDefinition.cs @@ -0,0 +1,55 @@ +// 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.Projects.OneDP +{ + /// A tool definition for the OpenAI File Search feature. + public partial class FileSearchToolDefinition : AgentToolDefinition + { + /// Initializes a new instance of . + /// A list of file IDs to be searched. + /// is null. + public FileSearchToolDefinition(IEnumerable fileIds) + { + Argument.AssertNotNull(fileIds, nameof(fileIds)); + + Type = "OpenAI.FileSearch"; + FileIds = fileIds.ToList(); + } + + /// Initializes a new instance of . + /// Discriminates the various child 'tool definition' types. + /// Additional options that specify the behavior of this tool (also polymorphic). + /// A set of overrides for the tool's name, description, or parameters. + /// Keeps track of any properties unknown to the library. + /// The maximum number of search results to return (optional). + /// Extra ranking options, including a threshold and a ranker. + /// A list of file IDs to be searched. + internal FileSearchToolDefinition(string type, AgentToolOptions options, AgentToolDefinitionOverride @override, IDictionary serializedAdditionalRawData, int? maxNumResults, FileSearchToolDefinitionRankingOptions rankingOptions, IList fileIds) : base(type, options, @override, serializedAdditionalRawData) + { + MaxNumResults = maxNumResults; + RankingOptions = rankingOptions; + FileIds = fileIds; + } + + /// Initializes a new instance of for deserialization. + internal FileSearchToolDefinition() + { + } + + /// The maximum number of search results to return (optional). + public int? MaxNumResults { get; set; } + /// Extra ranking options, including a threshold and a ranker. + public FileSearchToolDefinitionRankingOptions RankingOptions { get; set; } + /// A list of file IDs to be searched. + public IList FileIds { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileSearchToolDefinitionRankingOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileSearchToolDefinitionRankingOptions.Serialization.cs new file mode 100644 index 000000000000..fd601bfc18a9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileSearchToolDefinitionRankingOptions.Serialization.cs @@ -0,0 +1,157 @@ +// 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.Projects.OneDP +{ + public partial class FileSearchToolDefinitionRankingOptions : 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(FileSearchToolDefinitionRankingOptions)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ScoreThreshold)) + { + writer.WritePropertyName("scoreThreshold"u8); + writer.WriteNumberValue(ScoreThreshold.Value); + } + writer.WritePropertyName("ranker"u8); + writer.WriteStringValue(Ranker); + 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 + } + } + } + + FileSearchToolDefinitionRankingOptions 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(FileSearchToolDefinitionRankingOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileSearchToolDefinitionRankingOptions(document.RootElement, options); + } + + internal static FileSearchToolDefinitionRankingOptions DeserializeFileSearchToolDefinitionRankingOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + float? scoreThreshold = default; + string ranker = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("scoreThreshold"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + scoreThreshold = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("ranker"u8)) + { + ranker = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FileSearchToolDefinitionRankingOptions(scoreThreshold, ranker, 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(FileSearchToolDefinitionRankingOptions)} does not support writing '{options.Format}' format."); + } + } + + FileSearchToolDefinitionRankingOptions 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 DeserializeFileSearchToolDefinitionRankingOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileSearchToolDefinitionRankingOptions)} 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 FileSearchToolDefinitionRankingOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFileSearchToolDefinitionRankingOptions(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/ai/Azure.AI.Projects.OneDP/src/Generated/FileSearchToolDefinitionRankingOptions.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileSearchToolDefinitionRankingOptions.cs new file mode 100644 index 000000000000..bef112ff8111 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FileSearchToolDefinitionRankingOptions.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.Projects.OneDP +{ + /// The FileSearchToolDefinitionRankingOptions. + public partial class FileSearchToolDefinitionRankingOptions + { + /// + /// 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 name of the ranker algorithm. + /// is null. + public FileSearchToolDefinitionRankingOptions(string ranker) + { + Argument.AssertNotNull(ranker, nameof(ranker)); + + Ranker = ranker; + } + + /// Initializes a new instance of . + /// The minimum score to include (optional). + /// The name of the ranker algorithm. + /// Keeps track of any properties unknown to the library. + internal FileSearchToolDefinitionRankingOptions(float? scoreThreshold, string ranker, IDictionary serializedAdditionalRawData) + { + ScoreThreshold = scoreThreshold; + Ranker = ranker; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FileSearchToolDefinitionRankingOptions() + { + } + + /// The minimum score to include (optional). + public float? ScoreThreshold { get; set; } + /// The name of the ranker algorithm. + public string Ranker { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FolderDatasetVersion.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FolderDatasetVersion.Serialization.cs new file mode 100644 index 000000000000..942bfd012f0b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FolderDatasetVersion.Serialization.cs @@ -0,0 +1,197 @@ +// 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.Projects.OneDP +{ + public partial class FolderDatasetVersion : 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 override 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(FolderDatasetVersion)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + FolderDatasetVersion 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(FolderDatasetVersion)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFolderDatasetVersion(document.RootElement, options); + } + + internal static FolderDatasetVersion DeserializeFolderDatasetVersion(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string datasetUri = default; + DatasetType type = default; + bool? isReference = default; + string stage = default; + string id = default; + string name = default; + string version = default; + string description = default; + IDictionary tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("datasetUri"u8)) + { + datasetUri = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new DatasetType(property.Value.GetString()); + continue; + } + if (property.NameEquals("isReference"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isReference = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("stage"u8)) + { + stage = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("version"u8)) + { + version = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"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()); + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FolderDatasetVersion( + datasetUri, + type, + isReference, + stage, + id, + name, + version, + description, + tags ?? new ChangeTrackingDictionary(), + 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(FolderDatasetVersion)} does not support writing '{options.Format}' format."); + } + } + + FolderDatasetVersion 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 DeserializeFolderDatasetVersion(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FolderDatasetVersion)} 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 new FolderDatasetVersion FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFolderDatasetVersion(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FolderDatasetVersion.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FolderDatasetVersion.cs new file mode 100644 index 000000000000..bbfb905e640e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FolderDatasetVersion.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// FileDatasetVersion Definition. + public partial class FolderDatasetVersion : DatasetVersion + { + /// Initializes a new instance of . + /// [Required] Uri of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// is null. + public FolderDatasetVersion(string datasetUri) : base(datasetUri) + { + Argument.AssertNotNull(datasetUri, nameof(datasetUri)); + + Type = DatasetType.UriFolder; + } + + /// Initializes a new instance of . + /// [Required] Uri of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// Dataset type. + /// Indicates if dataset is reference only or managed by dataset service. If true, the underlying data will be deleted when the dataset version is deleted. + /// Asset stage. + /// A unique identifier for the asset, assetId probably?. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Keeps track of any properties unknown to the library. + internal FolderDatasetVersion(string datasetUri, DatasetType type, bool? isReference, string stage, string id, string name, string version, string description, IDictionary tags, IDictionary serializedAdditionalRawData) : base(datasetUri, type, isReference, stage, id, name, version, description, tags, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal FolderDatasetVersion() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FunctionToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FunctionToolDefinition.Serialization.cs new file mode 100644 index 000000000000..abe6df2b26a3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FunctionToolDefinition.Serialization.cs @@ -0,0 +1,203 @@ +// 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.Projects.OneDP +{ + public partial class FunctionToolDefinition : 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 override 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(FunctionToolDefinition)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(Parameters)) + { + writer.WritePropertyName("parameters"u8); + writer.WriteObjectValue(Parameters, options); + } + if (Optional.IsDefined(Strict)) + { + writer.WritePropertyName("strict"u8); + writer.WriteBooleanValue(Strict.Value); + } + } + + FunctionToolDefinition 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(FunctionToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFunctionToolDefinition(document.RootElement, options); + } + + internal static FunctionToolDefinition DeserializeFunctionToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string description = default; + JSONSchema parameters = default; + bool? strict = default; + string type = default; + AgentToolOptions options0 = default; + AgentToolDefinitionOverride @override = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("parameters"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + parameters = JSONSchema.DeserializeJSONSchema(property.Value, options); + continue; + } + if (property.NameEquals("strict"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + strict = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("options"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + options0 = AgentToolOptions.DeserializeAgentToolOptions(property.Value, options); + continue; + } + if (property.NameEquals("override"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + @override = AgentToolDefinitionOverride.DeserializeAgentToolDefinitionOverride(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FunctionToolDefinition( + type, + options0, + @override, + serializedAdditionalRawData, + name, + description, + parameters, + strict); + } + + 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(FunctionToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + FunctionToolDefinition 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 DeserializeFunctionToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FunctionToolDefinition)} 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 new FunctionToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFunctionToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FunctionToolDefinition.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FunctionToolDefinition.cs new file mode 100644 index 000000000000..d2e86064a4ce --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/FunctionToolDefinition.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Definitions for a function-based tool behavior. + public partial class FunctionToolDefinition : AgentToolDefinition + { + /// Initializes a new instance of . + /// The function/tool name. + /// is null. + public FunctionToolDefinition(string name) + { + Argument.AssertNotNull(name, nameof(name)); + + Type = "Function"; + Name = name; + } + + /// Initializes a new instance of . + /// Discriminates the various child 'tool definition' types. + /// Additional options that specify the behavior of this tool (also polymorphic). + /// A set of overrides for the tool's name, description, or parameters. + /// Keeps track of any properties unknown to the library. + /// The function/tool name. + /// An optional description for the function-based tool. + /// A JSON schema describing the function's parameters. + /// Indicates whether strict validation is required. + internal FunctionToolDefinition(string type, AgentToolOptions options, AgentToolDefinitionOverride @override, IDictionary serializedAdditionalRawData, string name, string description, JSONSchema parameters, bool? strict) : base(type, options, @override, serializedAdditionalRawData) + { + Name = name; + Description = description; + Parameters = parameters; + Strict = strict; + } + + /// Initializes a new instance of for deserialization. + internal FunctionToolDefinition() + { + } + + /// The function/tool name. + public string Name { get; set; } + /// An optional description for the function-based tool. + public string Description { get; set; } + /// A JSON schema describing the function's parameters. + public JSONSchema Parameters { get; set; } + /// Indicates whether strict validation is required. + public bool? Strict { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ImageContent.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ImageContent.Serialization.cs new file mode 100644 index 000000000000..d345e157227b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ImageContent.Serialization.cs @@ -0,0 +1,232 @@ +// 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.Projects.OneDP +{ + public partial class ImageContent : 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 override 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(ImageContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Width)) + { + writer.WritePropertyName("width"u8); + writer.WriteObjectValue(Width, options); + } + if (Optional.IsDefined(Height)) + { + writer.WritePropertyName("height"u8); + writer.WriteObjectValue(Height, options); + } + if (Optional.IsDefined(FileName)) + { + writer.WritePropertyName("fileName"u8); + writer.WriteStringValue(FileName); + } + if (Optional.IsDefined(MimeType)) + { + writer.WritePropertyName("mimeType"u8); + writer.WriteStringValue(MimeType); + } + if (Optional.IsDefined(Uri)) + { + writer.WritePropertyName("uri"u8); + writer.WriteStringValue(Uri.AbsoluteUri); + } + if (Optional.IsDefined(DataUri)) + { + writer.WritePropertyName("dataUri"u8); + writer.WriteStringValue(DataUri.AbsoluteUri); + } + if (Optional.IsDefined(Data)) + { + writer.WritePropertyName("data"u8); + writer.WriteBase64StringValue(Data.ToArray(), "D"); + } + } + + ImageContent 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(ImageContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeImageContent(document.RootElement, options); + } + + internal static ImageContent DeserializeImageContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + object width = default; + object height = default; + string fileName = default; + string mimeType = default; + Uri uri = default; + Uri dataUri = default; + BinaryData data = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("width"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + width = property.Value.GetObject(); + continue; + } + if (property.NameEquals("height"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + height = property.Value.GetObject(); + continue; + } + if (property.NameEquals("fileName"u8)) + { + fileName = property.Value.GetString(); + continue; + } + if (property.NameEquals("mimeType"u8)) + { + mimeType = property.Value.GetString(); + continue; + } + if (property.NameEquals("uri"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + uri = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("dataUri"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataUri = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("data"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + data = BinaryData.FromBytes(property.Value.GetBytesFromBase64("D")); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ImageContent( + type, + serializedAdditionalRawData, + width, + height, + fileName, + mimeType, + uri, + dataUri, + data); + } + + 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(ImageContent)} does not support writing '{options.Format}' format."); + } + } + + ImageContent 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 DeserializeImageContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ImageContent)} 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 new ImageContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeImageContent(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ImageContent.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ImageContent.cs new file mode 100644 index 000000000000..e8be74ddcbff --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ImageContent.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.Projects.OneDP +{ + /// A structured chat content item containing an image reference. + public partial class ImageContent : AIContent + { + /// Initializes a new instance of . + public ImageContent() + { + Type = "image"; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// Width of the image in pixels (optional). + /// Height of the image in pixels (optional). + /// The file name for this binary content. + /// The MIME type for this binary content. + /// URI where the binary content can be retrieved. + /// Data URI containing the binary content inlined. + /// Raw bytes for the binary content. + internal ImageContent(string type, IDictionary serializedAdditionalRawData, object width, object height, string fileName, string mimeType, Uri uri, Uri dataUri, BinaryData data) : base(type, serializedAdditionalRawData) + { + Width = width; + Height = height; + FileName = fileName; + MimeType = mimeType; + Uri = uri; + DataUri = dataUri; + Data = data; + } + + /// Width of the image in pixels (optional). + public object Width { get; set; } + /// Height of the image in pixels (optional). + public object Height { get; set; } + /// The file name for this binary content. + public string FileName { get; set; } + /// The MIME type for this binary content. + public string MimeType { get; set; } + /// URI where the binary content can be retrieved. + public Uri Uri { get; set; } + /// Data URI containing the binary content inlined. + public Uri DataUri { get; set; } + /// + /// Raw bytes for the binary content. + /// + /// To assign a byte[] to this property use . + /// The byte[] will be serialized to a Base64 encoded string. + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromBytes(new byte[] { 1, 2, 3 }) + /// Creates a payload of "AQID". + /// + /// + /// + /// + public BinaryData Data { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Index.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Index.Serialization.cs new file mode 100644 index 000000000000..0d8d86b12d26 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Index.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.Text.Json; +using Azure.Core; + +namespace Azure.AI.Projects.OneDP +{ + [PersistableModelProxy(typeof(UnknownIndex))] + public partial class Index : 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(Index)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (Optional.IsDefined(Stage)) + { + writer.WritePropertyName("stage"u8); + writer.WriteStringValue(Stage); + } + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + 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 + } + } + } + + Index 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(Index)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIndex(document.RootElement, options); + } + + internal static Index DeserializeIndex(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "AzureSearch": return AzureAISearchIndex.DeserializeAzureAISearchIndex(element, options); + case "CosmosDBNoSqlVectorStore": return CosmosDBIndex.DeserializeCosmosDBIndex(element, options); + case "ManagedAzureSearch": return ManagedAzureAISearchIndex.DeserializeManagedAzureAISearchIndex(element, options); + } + } + return UnknownIndex.DeserializeUnknownIndex(element, options); + } + + 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(Index)} does not support writing '{options.Format}' format."); + } + } + + Index 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 DeserializeIndex(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Index)} 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 Index FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeIndex(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/ai/Azure.AI.Projects.OneDP/src/Generated/Index.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Index.cs new file mode 100644 index 000000000000..4149c8a2c137 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Index.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// + /// Index resource Definition + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public abstract partial class Index + { + /// + /// 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 protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected Index() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Type of index. + /// Asset stage. + /// A unique identifier for the asset, assetId probably?. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Keeps track of any properties unknown to the library. + internal Index(IndexType type, string stage, string id, string name, string version, string description, IDictionary tags, IDictionary serializedAdditionalRawData) + { + Type = type; + Stage = stage; + Id = id; + Name = name; + Version = version; + Description = description; + Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Type of index. + internal IndexType Type { get; set; } + /// Asset stage. + public string Stage { get; set; } + /// A unique identifier for the asset, assetId probably?. + public string Id { get; } + /// The name of the resource. + public string Name { get; } + /// The version of the resource. + public string Version { get; } + /// The asset description text. + public string Description { get; set; } + /// Tag dictionary. Tags can be added, removed, and updated. + public IDictionary Tags { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/IndexType.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/IndexType.cs new file mode 100644 index 000000000000..4696e79c23b8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/IndexType.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects.OneDP +{ + /// Enumerates known index types, but also allows any custom string fallback. + internal readonly partial struct IndexType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public IndexType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AzureSearchValue = "AzureSearch"; + private const string CosmosDBValue = "CosmosDBNoSqlVectorStore"; + private const string ManagedAzureSearchValue = "ManagedAzureSearch"; + + /// Azure search. + public static IndexType AzureSearch { get; } = new IndexType(AzureSearchValue); + /// CosmosDB. + public static IndexType CosmosDB { get; } = new IndexType(CosmosDBValue); + /// Managed Azure Search. + public static IndexType ManagedAzureSearch { get; } = new IndexType(ManagedAzureSearchValue); + /// Determines if two values are the same. + public static bool operator ==(IndexType left, IndexType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(IndexType left, IndexType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator IndexType(string value) => new IndexType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is IndexType other && Equals(other); + /// + public bool Equals(IndexType 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/ai/Azure.AI.Projects.OneDP/src/Generated/Indexes.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Indexes.cs new file mode 100644 index 000000000000..e121bda7ebb9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Indexes.cs @@ -0,0 +1,879 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Projects.OneDP +{ + // Data plane generated sub-client. + /// The Indexes sub-client. + public partial class Indexes + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + 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 Indexes for mocking. + protected Indexes() + { + } + + /// Initializes a new instance of Indexes. + /// 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. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// The API version to use for this operation. + internal Indexes(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Get the specific version of the Index. + /// The name of the resource. + /// The specific version id of the Index to retrieve. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetVersionAsync(string name, string version, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetVersionAsync(name, version, context).ConfigureAwait(false); + return Response.FromValue(Index.FromResponse(response), response); + } + + /// Get the specific version of the Index. + /// The name of the resource. + /// The specific version id of the Index to retrieve. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response GetVersion(string name, string version, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetVersion(name, version, context); + return Response.FromValue(Index.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get the specific version of the Index + /// + /// + /// + /// 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 resource. + /// The specific version id of the Index to retrieve. + /// 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 GetVersionAsync(string name, string version, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = ClientDiagnostics.CreateScope("Indexes.GetVersion"); + scope.Start(); + try + { + using HttpMessage message = CreateGetVersionRequest(name, version, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get the specific version of the Index + /// + /// + /// + /// 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 resource. + /// The specific version id of the Index to retrieve. + /// 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 GetVersion(string name, string version, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = ClientDiagnostics.CreateScope("Indexes.GetVersion"); + scope.Start(); + try + { + using HttpMessage message = CreateGetVersionRequest(name, version, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete the specific version of the Index + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The name of the resource. + /// The version of the Index to delete. + /// 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 DeleteVersionAsync(string name, string version, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = ClientDiagnostics.CreateScope("Indexes.DeleteVersion"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteVersionRequest(name, version, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete the specific version of the Index + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The name of the resource. + /// The version of the Index to delete. + /// 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 DeleteVersion(string name, string version, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = ClientDiagnostics.CreateScope("Indexes.DeleteVersion"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteVersionRequest(name, version, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Create a new Index. The version id will be generated by the service. + /// The name of the resource. + /// The definition of the Index to create. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> CreateAsync(string name, Index body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateAsync(name, content, context).ConfigureAwait(false); + return Response.FromValue(Index.FromResponse(response), response); + } + + /// Create a new Index. The version id will be generated by the service. + /// The name of the resource. + /// The definition of the Index to create. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response Create(string name, Index body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = Create(name, content, context); + return Response.FromValue(Index.FromResponse(response), response); + } + + /// + /// [Protocol Method] Create a new Index. The version id will be generated by the service. + /// + /// + /// + /// 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 resource. + /// 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 CreateAsync(string name, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Indexes.Create"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateRequest(name, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create a new Index. The version id will be generated by the service. + /// + /// + /// + /// 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 resource. + /// 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 Create(string name, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Indexes.Create"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateRequest(name, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Create a new or replace an existing Index with the given version id. + /// The name of the resource. + /// The specific version id of the Index to create or replace. + /// The definition of the Index to create. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> CreateVersionAsync(string name, string version, Index body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateVersionAsync(name, version, content, context).ConfigureAwait(false); + return Response.FromValue(Index.FromResponse(response), response); + } + + /// Create a new or replace an existing Index with the given version id. + /// The name of the resource. + /// The specific version id of the Index to create or replace. + /// The definition of the Index to create. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response CreateVersion(string name, string version, Index body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CreateVersion(name, version, content, context); + return Response.FromValue(Index.FromResponse(response), response); + } + + /// + /// [Protocol Method] Create a new or replace an existing Index with the given version id + /// + /// + /// + /// 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 resource. + /// The specific version id of the Index to create or replace. + /// 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. + /// 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 CreateVersionAsync(string name, string version, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Indexes.CreateVersion"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateVersionRequest(name, version, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create a new or replace an existing Index with the given version id + /// + /// + /// + /// 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 resource. + /// The specific version id of the Index to create or replace. + /// 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. + /// 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 CreateVersion(string name, string version, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Indexes.CreateVersion"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateVersionRequest(name, version, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List all versions of the given Index. + /// The name of the resource. + /// Top count of results, top count cannot be greater than the page size. If topCount is larger than page size, results with be default page size count will be returned. + /// Continuation token for pagination. + /// Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2. + /// [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual AsyncPageable GetVersionsAsync(string name, int? maxCount = null, string skip = null, string tags = null, ListViewType? listViewType = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetVersionsRequest(name, maxCount, skip, tags, listViewType?.ToString(), context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetVersionsNextPageRequest(nextLink, name, maxCount, skip, tags, listViewType?.ToString(), context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Index.DeserializeIndex(e), ClientDiagnostics, _pipeline, "Indexes.GetVersions", "value", "nextLink", context); + } + + /// List all versions of the given Index. + /// The name of the resource. + /// Top count of results, top count cannot be greater than the page size. If topCount is larger than page size, results with be default page size count will be returned. + /// Continuation token for pagination. + /// Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2. + /// [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Pageable GetVersions(string name, int? maxCount = null, string skip = null, string tags = null, ListViewType? listViewType = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetVersionsRequest(name, maxCount, skip, tags, listViewType?.ToString(), context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetVersionsNextPageRequest(nextLink, name, maxCount, skip, tags, listViewType?.ToString(), context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Index.DeserializeIndex(e), ClientDiagnostics, _pipeline, "Indexes.GetVersions", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List all versions of the given Index + /// + /// + /// + /// 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 resource. + /// Top count of results, top count cannot be greater than the page size. If topCount is larger than page size, results with be default page size count will be returned. + /// Continuation token for pagination. + /// Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2. + /// [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. Allowed values: "ActiveOnly" | "ArchivedOnly" | "All". + /// 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 GetVersionsAsync(string name, int? maxCount, string skip, string tags, string listViewType, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetVersionsRequest(name, maxCount, skip, tags, listViewType, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetVersionsNextPageRequest(nextLink, name, maxCount, skip, tags, listViewType, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Indexes.GetVersions", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List all versions of the given Index + /// + /// + /// + /// 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 resource. + /// Top count of results, top count cannot be greater than the page size. If topCount is larger than page size, results with be default page size count will be returned. + /// Continuation token for pagination. + /// Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2. + /// [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. Allowed values: "ActiveOnly" | "ArchivedOnly" | "All". + /// 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 GetVersions(string name, int? maxCount, string skip, string tags, string listViewType, RequestContext context) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetVersionsRequest(name, maxCount, skip, tags, listViewType, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetVersionsNextPageRequest(nextLink, name, maxCount, skip, tags, listViewType, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Indexes.GetVersions", "value", "nextLink", context); + } + + /// List the latest version of each Index. + /// Top count of results, top count cannot be greater than the page size. If topCount is larger than page size, results with be default page size count will be returned. + /// Continuation token for pagination. + /// Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2. + /// [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. + /// The cancellation token to use. + /// + public virtual AsyncPageable GetLatestsAsync(int? maxCount = null, string skip = null, string tags = null, ListViewType? listViewType = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetLatestsRequest(maxCount, skip, tags, listViewType?.ToString(), context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetLatestsNextPageRequest(nextLink, maxCount, skip, tags, listViewType?.ToString(), context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Index.DeserializeIndex(e), ClientDiagnostics, _pipeline, "Indexes.GetLatests", "value", "nextLink", context); + } + + /// List the latest version of each Index. + /// Top count of results, top count cannot be greater than the page size. If topCount is larger than page size, results with be default page size count will be returned. + /// Continuation token for pagination. + /// Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2. + /// [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. + /// The cancellation token to use. + /// + public virtual Pageable GetLatests(int? maxCount = null, string skip = null, string tags = null, ListViewType? listViewType = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetLatestsRequest(maxCount, skip, tags, listViewType?.ToString(), context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetLatestsNextPageRequest(nextLink, maxCount, skip, tags, listViewType?.ToString(), context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Index.DeserializeIndex(e), ClientDiagnostics, _pipeline, "Indexes.GetLatests", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List the latest version of each Index + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Top count of results, top count cannot be greater than the page size. If topCount is larger than page size, results with be default page size count will be returned. + /// Continuation token for pagination. + /// Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2. + /// [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. Allowed values: "ActiveOnly" | "ArchivedOnly" | "All". + /// 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 GetLatestsAsync(int? maxCount, string skip, string tags, string listViewType, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetLatestsRequest(maxCount, skip, tags, listViewType, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetLatestsNextPageRequest(nextLink, maxCount, skip, tags, listViewType, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Indexes.GetLatests", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List the latest version of each Index + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Top count of results, top count cannot be greater than the page size. If topCount is larger than page size, results with be default page size count will be returned. + /// Continuation token for pagination. + /// Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2. + /// [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. Allowed values: "ActiveOnly" | "ArchivedOnly" | "All". + /// 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 GetLatests(int? maxCount, string skip, string tags, string listViewType, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetLatestsRequest(maxCount, skip, tags, listViewType, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetLatestsNextPageRequest(nextLink, maxCount, skip, tags, listViewType, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Indexes.GetLatests", "value", "nextLink", context); + } + + internal HttpMessage CreateGetVersionsRequest(string name, int? maxCount, string skip, string tags, string listViewType, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/indexes/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (maxCount != null) + { + uri.AppendQuery("top", maxCount.Value, true); + } + if (skip != null) + { + uri.AppendQuery("skip", skip, true); + } + if (tags != null) + { + uri.AppendQuery("tags", tags, true); + } + if (listViewType != null) + { + uri.AppendQuery("listViewType", listViewType, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetLatestsRequest(int? maxCount, string skip, string tags, string listViewType, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/indexes", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (maxCount != null) + { + uri.AppendQuery("top", maxCount.Value, true); + } + if (skip != null) + { + uri.AppendQuery("skip", skip, true); + } + if (tags != null) + { + uri.AppendQuery("tags", tags, true); + } + if (listViewType != null) + { + uri.AppendQuery("listViewType", listViewType, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetVersionRequest(string name, string version, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/indexes/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(version, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateDeleteVersionRequest(string name, string version, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/indexes/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(version, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateRequest(string name, 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.AppendPath("/indexes/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Repeatability-Request-ID", Guid.NewGuid()); + request.Headers.Add("Repeatability-First-Sent", DateTimeOffset.Now, "R"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateCreateVersionRequest(string name, string version, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/indexes/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(version, 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 CreateGetVersionsNextPageRequest(string nextLink, string name, int? maxCount, string skip, string tags, string listViewType, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetLatestsNextPageRequest(string nextLink, int? maxCount, string skip, string tags, string listViewType, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + 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 }); + private static ResponseClassifier _responseClassifier204; + private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); + private static ResponseClassifier _responseClassifier200201; + private static ResponseClassifier ResponseClassifier200201 => _responseClassifier200201 ??= new StatusCodeClassifier(stackalloc ushort[] { 200, 201 }); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/InputData.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/InputData.Serialization.cs new file mode 100644 index 000000000000..3772ce645f20 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/InputData.Serialization.cs @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Projects.OneDP +{ + [PersistableModelProxy(typeof(UnknownInputData))] + public partial class InputData : 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(InputData)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + 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 + } + } + } + + InputData 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(InputData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInputData(document.RootElement, options); + } + + internal static InputData DeserializeInputData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "dataset": return InputDataset.DeserializeInputDataset(element, options); + } + } + return UnknownInputData.DeserializeUnknownInputData(element, options); + } + + 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(InputData)} does not support writing '{options.Format}' format."); + } + } + + InputData 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 DeserializeInputData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InputData)} 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 InputData FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInputData(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/ai/Azure.AI.Projects.OneDP/src/Generated/InputData.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/InputData.cs new file mode 100644 index 000000000000..a36ded9d09e5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/InputData.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.Projects.OneDP +{ + /// + /// Abstract data class. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + public abstract partial class InputData + { + /// + /// 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 protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected InputData() + { + } + + /// Initializes a new instance of . + /// Type of the data. + /// Keeps track of any properties unknown to the library. + internal InputData(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Type of the data. + internal string Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/InputDataset.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/InputDataset.Serialization.cs new file mode 100644 index 000000000000..ce3d476d0289 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/InputDataset.Serialization.cs @@ -0,0 +1,134 @@ +// 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.Projects.OneDP +{ + public partial class InputDataset : 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 override 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(InputDataset)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + + InputDataset 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(InputDataset)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInputDataset(document.RootElement, options); + } + + internal static InputDataset DeserializeInputDataset(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string type = 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("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InputDataset(type, serializedAdditionalRawData, id); + } + + 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(InputDataset)} does not support writing '{options.Format}' format."); + } + } + + InputDataset 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 DeserializeInputDataset(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InputDataset)} 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 new InputDataset FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInputDataset(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/InputDataset.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/InputDataset.cs new file mode 100644 index 000000000000..8a3b357b6090 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/InputDataset.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Dataset as source for evaluation. + public partial class InputDataset : InputData + { + /// Initializes a new instance of . + /// Evaluation input data. + /// is null. + public InputDataset(string id) + { + Argument.AssertNotNull(id, nameof(id)); + + Type = "dataset"; + Id = id; + } + + /// Initializes a new instance of . + /// Type of the data. + /// Keeps track of any properties unknown to the library. + /// Evaluation input data. + internal InputDataset(string type, IDictionary serializedAdditionalRawData, string id) : base(type, serializedAdditionalRawData) + { + Id = id; + } + + /// Initializes a new instance of for deserialization. + internal InputDataset() + { + } + + /// Evaluation input data. + public string Id { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Internal/Argument.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..3a95ec218792 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/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.Projects.OneDP +{ + 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/ai/Azure.AI.Projects.OneDP/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..6063557c10d9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/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.Projects.OneDP +{ + 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/ai/Azure.AI.Projects.OneDP/src/Generated/Internal/ChangeTrackingList.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..170b6bb22347 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/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.Projects.OneDP +{ + 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/ai/Azure.AI.Projects.OneDP/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..c354798cd985 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/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.Projects.OneDP +{ + 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/ai/Azure.AI.Projects.OneDP/src/Generated/Internal/Optional.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..0c7fa3e8c3b4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/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.Projects.OneDP +{ + 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/ai/Azure.AI.Projects.OneDP/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..46730667bd96 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/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.Projects.OneDP +{ + 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/ai/Azure.AI.Projects.OneDP/src/Generated/JSONAny.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/JSONAny.Serialization.cs new file mode 100644 index 000000000000..6e3fcd9629ad --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/JSONAny.Serialization.cs @@ -0,0 +1,264 @@ +// 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.Projects.OneDP +{ + public partial class JSONAny : 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(JSONAny)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(StringValue)) + { + writer.WritePropertyName("stringValue"u8); + writer.WriteStringValue(StringValue); + } + if (Optional.IsDefined(IntValue)) + { + writer.WritePropertyName("intValue"u8); + writer.WriteNumberValue(IntValue.Value); + } + if (Optional.IsDefined(FloatValue)) + { + writer.WritePropertyName("floatValue"u8); + writer.WriteNumberValue(FloatValue.Value); + } + if (Optional.IsDefined(BoolValue)) + { + writer.WritePropertyName("boolValue"u8); + writer.WriteBooleanValue(BoolValue.Value); + } + if (Optional.IsDefined(NullValue)) + { + writer.WritePropertyName("nullValue"u8); + writer.WriteBooleanValue(NullValue.Value); + } + if (Optional.IsCollectionDefined(ArrayValue)) + { + writer.WritePropertyName("arrayValue"u8); + writer.WriteStartArray(); + foreach (var item in ArrayValue) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(ObjectValue)) + { + writer.WritePropertyName("objectValue"u8); + writer.WriteStartObject(); + foreach (var item in ObjectValue) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + 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 + } + } + } + + JSONAny 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(JSONAny)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeJSONAny(document.RootElement, options); + } + + internal static JSONAny DeserializeJSONAny(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string stringValue = default; + long? intValue = default; + double? floatValue = default; + bool? boolValue = default; + bool? nullValue = default; + IList arrayValue = default; + IDictionary objectValue = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("stringValue"u8)) + { + stringValue = property.Value.GetString(); + continue; + } + if (property.NameEquals("intValue"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + intValue = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("floatValue"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + floatValue = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("boolValue"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + boolValue = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("nullValue"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nullValue = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("arrayValue"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DeserializeJSONAny(item, options)); + } + arrayValue = array; + continue; + } + if (property.NameEquals("objectValue"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, DeserializeJSONAny(property0.Value, options)); + } + objectValue = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new JSONAny( + stringValue, + intValue, + floatValue, + boolValue, + nullValue, + arrayValue ?? new ChangeTrackingList(), + objectValue ?? new ChangeTrackingDictionary(), + 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(JSONAny)} does not support writing '{options.Format}' format."); + } + } + + JSONAny 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 DeserializeJSONAny(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(JSONAny)} 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 JSONAny FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeJSONAny(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/ai/Azure.AI.Projects.OneDP/src/Generated/JSONAny.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/JSONAny.cs new file mode 100644 index 000000000000..118264730a51 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/JSONAny.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// A JSON-compatible type that can be a primitive, object, or array. + public partial class JSONAny + { + /// + /// 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 JSONAny() + { + ArrayValue = new ChangeTrackingList(); + ObjectValue = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// A string value, if present. + /// A 64-bit integer value, if present. + /// A floating-point (double precision) value, if present. + /// A boolean value, if present. + /// Indicates this represents a JSON null if set to true. + /// A JSON array, if present, expressed as an array of JSONAny elements. + /// A JSON object, if present, expressed as a dictionary from string to JSONAny. + /// Keeps track of any properties unknown to the library. + internal JSONAny(string stringValue, long? intValue, double? floatValue, bool? boolValue, bool? nullValue, IList arrayValue, IDictionary objectValue, IDictionary serializedAdditionalRawData) + { + StringValue = stringValue; + IntValue = intValue; + FloatValue = floatValue; + BoolValue = boolValue; + NullValue = nullValue; + ArrayValue = arrayValue; + ObjectValue = objectValue; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// A string value, if present. + public string StringValue { get; set; } + /// A 64-bit integer value, if present. + public long? IntValue { get; set; } + /// A floating-point (double precision) value, if present. + public double? FloatValue { get; set; } + /// A boolean value, if present. + public bool? BoolValue { get; set; } + /// Indicates this represents a JSON null if set to true. + public bool? NullValue { get; set; } + /// A JSON array, if present, expressed as an array of JSONAny elements. + public IList ArrayValue { get; } + /// A JSON object, if present, expressed as a dictionary from string to JSONAny. + public IDictionary ObjectValue { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/JSONSchema.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/JSONSchema.Serialization.cs new file mode 100644 index 000000000000..8e9b6f30acc1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/JSONSchema.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.Projects.OneDP +{ + public partial class JSONSchema : 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(JSONSchema)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + foreach (var item in Properties) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + if (Optional.IsCollectionDefined(Required)) + { + writer.WritePropertyName("required"u8); + writer.WriteStartArray(); + foreach (var item in Required) + { + 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 + } + } + } + + JSONSchema 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(JSONSchema)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeJSONSchema(document.RootElement, options); + } + + internal static JSONSchema DeserializeJSONSchema(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + IDictionary properties = default; + IList required = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, DeserializeJSONSchema(property0.Value, options)); + } + properties = dictionary; + continue; + } + if (property.NameEquals("required"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + required = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new JSONSchema(type, properties, required ?? 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(JSONSchema)} does not support writing '{options.Format}' format."); + } + } + + JSONSchema 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 DeserializeJSONSchema(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(JSONSchema)} 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 JSONSchema FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeJSONSchema(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/ai/Azure.AI.Projects.OneDP/src/Generated/JSONSchema.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/JSONSchema.cs new file mode 100644 index 000000000000..7d26dee54355 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/JSONSchema.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Represents a JSON schema describing object properties and required fields. + public partial class JSONSchema + { + /// + /// 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 JSON schema type (e.g., 'object', 'string', 'number'). + /// The properties defined in this JSON schema. + /// or is null. + public JSONSchema(string type, IDictionary properties) + { + Argument.AssertNotNull(type, nameof(type)); + Argument.AssertNotNull(properties, nameof(properties)); + + Type = type; + Properties = properties; + Required = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The JSON schema type (e.g., 'object', 'string', 'number'). + /// The properties defined in this JSON schema. + /// A list of required property names in this schema. + /// Keeps track of any properties unknown to the library. + internal JSONSchema(string type, IDictionary properties, IList required, IDictionary serializedAdditionalRawData) + { + Type = type; + Properties = properties; + Required = required; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal JSONSchema() + { + } + + /// The JSON schema type (e.g., 'object', 'string', 'number'). + public string Type { get; set; } + /// The properties defined in this JSON schema. + public IDictionary Properties { get; } + /// A list of required property names in this schema. + public IList Required { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ListViewType.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ListViewType.cs new file mode 100644 index 000000000000..3dbd14873aea --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ListViewType.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects.OneDP +{ + /// List View Type Definition. + public readonly partial struct ListViewType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ListViewType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ActiveOnlyValue = "ActiveOnly"; + private const string ArchivedOnlyValue = "ArchivedOnly"; + private const string AllValue = "All"; + + /// List only active items. + public static ListViewType ActiveOnly { get; } = new ListViewType(ActiveOnlyValue); + /// List only archived items. + public static ListViewType ArchivedOnly { get; } = new ListViewType(ArchivedOnlyValue); + /// List all items. + public static ListViewType All { get; } = new ListViewType(AllValue); + /// Determines if two values are the same. + public static bool operator ==(ListViewType left, ListViewType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ListViewType left, ListViewType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ListViewType(string value) => new ListViewType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ListViewType other && Equals(other); + /// + public bool Equals(ListViewType 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/ai/Azure.AI.Projects.OneDP/src/Generated/ManagedAzureAISearchIndex.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ManagedAzureAISearchIndex.Serialization.cs new file mode 100644 index 000000000000..f185c51bbd5c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ManagedAzureAISearchIndex.Serialization.cs @@ -0,0 +1,188 @@ +// 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.Projects.OneDP +{ + public partial class ManagedAzureAISearchIndex : 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 override 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(ManagedAzureAISearchIndex)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("vectorStoreId"u8); + writer.WriteStringValue(VectorStoreId); + } + + ManagedAzureAISearchIndex 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(ManagedAzureAISearchIndex)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedAzureAISearchIndex(document.RootElement, options); + } + + internal static ManagedAzureAISearchIndex DeserializeManagedAzureAISearchIndex(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string vectorStoreId = default; + IndexType type = default; + string stage = default; + string id = default; + string name = default; + string version = default; + string description = default; + IDictionary tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("vectorStoreId"u8)) + { + vectorStoreId = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new IndexType(property.Value.GetString()); + continue; + } + if (property.NameEquals("stage"u8)) + { + stage = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("version"u8)) + { + version = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"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()); + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ManagedAzureAISearchIndex( + type, + stage, + id, + name, + version, + description, + tags ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData, + vectorStoreId); + } + + 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(ManagedAzureAISearchIndex)} does not support writing '{options.Format}' format."); + } + } + + ManagedAzureAISearchIndex 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 DeserializeManagedAzureAISearchIndex(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedAzureAISearchIndex)} 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 new ManagedAzureAISearchIndex FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeManagedAzureAISearchIndex(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ManagedAzureAISearchIndex.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ManagedAzureAISearchIndex.cs new file mode 100644 index 000000000000..ecb6fe7d5607 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ManagedAzureAISearchIndex.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Managed Azure AI Search Index Definition. + public partial class ManagedAzureAISearchIndex : Index + { + /// Initializes a new instance of . + /// Vector store id of managed index. + /// is null. + public ManagedAzureAISearchIndex(string vectorStoreId) + { + Argument.AssertNotNull(vectorStoreId, nameof(vectorStoreId)); + + Type = IndexType.ManagedAzureSearch; + VectorStoreId = vectorStoreId; + } + + /// Initializes a new instance of . + /// Type of index. + /// Asset stage. + /// A unique identifier for the asset, assetId probably?. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Keeps track of any properties unknown to the library. + /// Vector store id of managed index. + internal ManagedAzureAISearchIndex(IndexType type, string stage, string id, string name, string version, string description, IDictionary tags, IDictionary serializedAdditionalRawData, string vectorStoreId) : base(type, stage, id, name, version, description, tags, serializedAdditionalRawData) + { + VectorStoreId = vectorStoreId; + } + + /// Initializes a new instance of for deserialization. + internal ManagedAzureAISearchIndex() + { + } + + /// Vector store id of managed index. + public string VectorStoreId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Messages.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Messages.cs new file mode 100644 index 000000000000..c0ff9887b7a5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Messages.cs @@ -0,0 +1,716 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Projects.OneDP +{ + // Data plane generated sub-client. + /// + /// MESSAGES + /// + /// The interface is rooted at /conversations/{conversationId}/messages. + /// + public partial class Messages + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + 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 Messages for mocking. + protected Messages() + { + } + + /// Initializes a new instance of Messages. + /// 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. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// The API version to use for this operation. + internal Messages(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Creates (sends) a new chat message, returning the created ChatMessage. + /// The ID of the conversation. + /// The message to create. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> SendMessageAsync(string conversationId, ChatMessage body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await SendMessageAsync(conversationId, content, context).ConfigureAwait(false); + return Response.FromValue(ChatMessage.FromResponse(response), response); + } + + /// Creates (sends) a new chat message, returning the created ChatMessage. + /// The ID of the conversation. + /// The message to create. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response SendMessage(string conversationId, ChatMessage body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = SendMessage(conversationId, content, context); + return Response.FromValue(ChatMessage.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates (sends) a new chat message, returning the created ChatMessage. + /// + /// + /// + /// 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 ID of the conversation. + /// 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 SendMessageAsync(string conversationId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Messages.SendMessage"); + scope.Start(); + try + { + using HttpMessage message = CreateSendMessageRequest(conversationId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates (sends) a new chat message, returning the created ChatMessage. + /// + /// + /// + /// 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 ID of the conversation. + /// 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 SendMessage(string conversationId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Messages.SendMessage"); + scope.Start(); + try + { + using HttpMessage message = CreateSendMessageRequest(conversationId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieves (reads) an existing chat message. + /// A unique identifier for this conversation. + /// A unique identifier for this message. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetMessageAsync(string conversationId, string messageId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetMessageAsync(conversationId, messageId, context).ConfigureAwait(false); + return Response.FromValue(ChatMessage.FromResponse(response), response); + } + + /// Retrieves (reads) an existing chat message. + /// A unique identifier for this conversation. + /// A unique identifier for this message. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response GetMessage(string conversationId, string messageId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetMessage(conversationId, messageId, context); + return Response.FromValue(ChatMessage.FromResponse(response), response); + } + + /// + /// [Protocol Method] Retrieves (reads) an existing chat message. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// A unique identifier for this conversation. + /// A unique identifier for this message. + /// 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 GetMessageAsync(string conversationId, string messageId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + using var scope = ClientDiagnostics.CreateScope("Messages.GetMessage"); + scope.Start(); + try + { + using HttpMessage message = CreateGetMessageRequest(conversationId, messageId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Retrieves (reads) an existing chat message. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// A unique identifier for this conversation. + /// A unique identifier for this message. + /// 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 GetMessage(string conversationId, string messageId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + using var scope = ClientDiagnostics.CreateScope("Messages.GetMessage"); + scope.Start(); + try + { + using HttpMessage message = CreateGetMessageRequest(conversationId, messageId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Updates an existing chat message (or creates if not found) and returns the updated message. + /// A unique identifier for this conversation. + /// A unique identifier for this message. + /// The resource instance. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> UpdateMessageAsync(string conversationId, string messageId, ChatMessage resource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNull(resource, nameof(resource)); + + using RequestContent content = resource.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await UpdateMessageAsync(conversationId, messageId, content, context).ConfigureAwait(false); + return Response.FromValue(ChatMessage.FromResponse(response), response); + } + + /// Updates an existing chat message (or creates if not found) and returns the updated message. + /// A unique identifier for this conversation. + /// A unique identifier for this message. + /// The resource instance. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response UpdateMessage(string conversationId, string messageId, ChatMessage resource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNull(resource, nameof(resource)); + + using RequestContent content = resource.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = UpdateMessage(conversationId, messageId, content, context); + return Response.FromValue(ChatMessage.FromResponse(response), response); + } + + /// + /// [Protocol Method] Updates an existing chat message (or creates if not found) and returns the updated message. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// A unique identifier for this conversation. + /// A unique identifier for this message. + /// 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. + /// 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 UpdateMessageAsync(string conversationId, string messageId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Messages.UpdateMessage"); + scope.Start(); + try + { + using HttpMessage message = CreateUpdateMessageRequest(conversationId, messageId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Updates an existing chat message (or creates if not found) and returns the updated message. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// A unique identifier for this conversation. + /// A unique identifier for this message. + /// 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. + /// 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 UpdateMessage(string conversationId, string messageId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Messages.UpdateMessage"); + scope.Start(); + try + { + using HttpMessage message = CreateUpdateMessageRequest(conversationId, messageId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Deletes a chat message. Returns 204 on success. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// A unique identifier for this conversation. + /// A unique identifier for this message. + /// 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 DeleteMessageAsync(string conversationId, string messageId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + using var scope = ClientDiagnostics.CreateScope("Messages.DeleteMessage"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteMessageRequest(conversationId, messageId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Deletes a chat message. Returns 204 on success. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// A unique identifier for this conversation. + /// A unique identifier for this message. + /// 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 DeleteMessage(string conversationId, string messageId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + using var scope = ClientDiagnostics.CreateScope("Messages.DeleteMessage"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteMessageRequest(conversationId, messageId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Lists chat messages, returning a collection of ChatMessage objects. + /// A unique identifier for this conversation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual AsyncPageable GetMessagesAsync(string conversationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMessagesRequest(conversationId, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMessagesNextPageRequest(nextLink, conversationId, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => ChatMessage.DeserializeChatMessage(e), ClientDiagnostics, _pipeline, "Messages.GetMessages", "value", "nextLink", context); + } + + /// Lists chat messages, returning a collection of ChatMessage objects. + /// A unique identifier for this conversation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Pageable GetMessages(string conversationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMessagesRequest(conversationId, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMessagesNextPageRequest(nextLink, conversationId, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => ChatMessage.DeserializeChatMessage(e), ClientDiagnostics, _pipeline, "Messages.GetMessages", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Lists chat messages, returning a collection of ChatMessage objects. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// A unique identifier for this conversation. + /// 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 GetMessagesAsync(string conversationId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMessagesRequest(conversationId, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMessagesNextPageRequest(nextLink, conversationId, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Messages.GetMessages", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Lists chat messages, returning a collection of ChatMessage objects. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// A unique identifier for this conversation. + /// 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 GetMessages(string conversationId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMessagesRequest(conversationId, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMessagesNextPageRequest(nextLink, conversationId, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Messages.GetMessages", "value", "nextLink", context); + } + + internal HttpMessage CreateSendMessageRequest(string conversationId, 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.AppendPath("/conversations/", false); + uri.AppendPath(conversationId, true); + uri.AppendPath("/messages", 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; + } + + internal HttpMessage CreateGetMessageRequest(string conversationId, string messageId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/conversations/", false); + uri.AppendPath(conversationId, true); + uri.AppendPath("/message/", false); + uri.AppendPath(messageId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateUpdateMessageRequest(string conversationId, string messageId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/conversations/", false); + uri.AppendPath(conversationId, true); + uri.AppendPath("/message/", false); + uri.AppendPath(messageId, 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 CreateDeleteMessageRequest(string conversationId, string messageId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/conversations/", false); + uri.AppendPath(conversationId, true); + uri.AppendPath("/message/", false); + uri.AppendPath(messageId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMessagesRequest(string conversationId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/conversations/", false); + uri.AppendPath(conversationId, true); + uri.AppendPath("/message", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMessagesNextPageRequest(string nextLink, string conversationId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + 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 }); + private static ResponseClassifier _responseClassifier200201; + private static ResponseClassifier ResponseClassifier200201 => _responseClassifier200201 ??= new StatusCodeClassifier(stackalloc ushort[] { 200, 201 }); + private static ResponseClassifier _responseClassifier204; + private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ModelDeployment.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ModelDeployment.Serialization.cs new file mode 100644 index 000000000000..4902bdc1c08f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ModelDeployment.Serialization.cs @@ -0,0 +1,218 @@ +// 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.Projects.OneDP +{ + public partial class ModelDeployment : 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 override 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(ModelDeployment)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (options.Format != "W") + { + writer.WritePropertyName("modelName"u8); + writer.WriteStringValue(ModelName); + } + if (options.Format != "W") + { + writer.WritePropertyName("modelVersion"u8); + writer.WriteStringValue(ModelVersion); + } + if (options.Format != "W") + { + writer.WritePropertyName("modelPublisher"u8); + writer.WriteStringValue(ModelPublisher); + } + if (options.Format != "W") + { + writer.WritePropertyName("capabilities"u8); + writer.WriteStartObject(); + foreach (var item in Capabilities) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W") + { + writer.WritePropertyName("sku"u8); + writer.WriteObjectValue(Sku, options); + } + if (options.Format != "W" && Optional.IsDefined(ConnectionName)) + { + writer.WritePropertyName("connectionName"u8); + writer.WriteStringValue(ConnectionName); + } + } + + ModelDeployment 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(ModelDeployment)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeModelDeployment(document.RootElement, options); + } + + internal static ModelDeployment DeserializeModelDeployment(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string modelName = default; + string modelVersion = default; + string modelPublisher = default; + IReadOnlyDictionary capabilities = default; + Sku sku = default; + string connectionName = default; + DeploymentType type = default; + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("modelName"u8)) + { + modelName = property.Value.GetString(); + continue; + } + if (property.NameEquals("modelVersion"u8)) + { + modelVersion = property.Value.GetString(); + continue; + } + if (property.NameEquals("modelPublisher"u8)) + { + modelPublisher = property.Value.GetString(); + continue; + } + if (property.NameEquals("capabilities"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + capabilities = dictionary; + continue; + } + if (property.NameEquals("sku"u8)) + { + sku = Sku.DeserializeSku(property.Value, options); + continue; + } + if (property.NameEquals("connectionName"u8)) + { + connectionName = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new DeploymentType(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ModelDeployment( + type, + name, + serializedAdditionalRawData, + modelName, + modelVersion, + modelPublisher, + capabilities, + sku, + connectionName); + } + + 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(ModelDeployment)} does not support writing '{options.Format}' format."); + } + } + + ModelDeployment 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 DeserializeModelDeployment(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ModelDeployment)} 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 new ModelDeployment FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeModelDeployment(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ModelDeployment.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ModelDeployment.cs new file mode 100644 index 000000000000..7841f691ebe4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ModelDeployment.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Model Deployment Definition. + public partial class ModelDeployment : Deployment + { + /// Initializes a new instance of . + internal ModelDeployment() + { + Type = DeploymentType.ModelDeployment; + Capabilities = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The type of the deployment. + /// Name of the deployment. + /// Keeps track of any properties unknown to the library. + /// Publisher-specific name of the deployed model. + /// Publisher-specific version of the deployed model. + /// Name of the deployed model's publisher. + /// Capabilities of deployed model. + /// Sku of the model deployment. + /// Name of the connection the deployment comes from. + internal ModelDeployment(DeploymentType type, string name, IDictionary serializedAdditionalRawData, string modelName, string modelVersion, string modelPublisher, IReadOnlyDictionary capabilities, Sku sku, string connectionName) : base(type, name, serializedAdditionalRawData) + { + ModelName = modelName; + ModelVersion = modelVersion; + ModelPublisher = modelPublisher; + Capabilities = capabilities; + Sku = sku; + ConnectionName = connectionName; + } + + /// Publisher-specific name of the deployed model. + public string ModelName { get; } + /// Publisher-specific version of the deployed model. + public string ModelVersion { get; } + /// Name of the deployed model's publisher. + public string ModelPublisher { get; } + /// Capabilities of deployed model. + public IReadOnlyDictionary Capabilities { get; } + /// Sku of the model deployment. + public Sku Sku { get; } + /// Name of the connection the deployment comes from. + public string ConnectionName { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/NoneToolChoiceBehavior.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/NoneToolChoiceBehavior.Serialization.cs new file mode 100644 index 000000000000..692bd5b3392c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/NoneToolChoiceBehavior.Serialization.cs @@ -0,0 +1,126 @@ +// 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.Projects.OneDP +{ + public partial class NoneToolChoiceBehavior : 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 override 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(NoneToolChoiceBehavior)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + NoneToolChoiceBehavior 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(NoneToolChoiceBehavior)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNoneToolChoiceBehavior(document.RootElement, options); + } + + internal static NoneToolChoiceBehavior DeserializeNoneToolChoiceBehavior(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NoneToolChoiceBehavior(type, 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(NoneToolChoiceBehavior)} does not support writing '{options.Format}' format."); + } + } + + NoneToolChoiceBehavior 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 DeserializeNoneToolChoiceBehavior(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NoneToolChoiceBehavior)} 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 new NoneToolChoiceBehavior FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNoneToolChoiceBehavior(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/NoneToolChoiceBehavior.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/NoneToolChoiceBehavior.cs new file mode 100644 index 000000000000..773c944516db --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/NoneToolChoiceBehavior.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Behavior specifying that no tools may be chosen. + public partial class NoneToolChoiceBehavior : ToolChoiceBehavior + { + /// Initializes a new instance of . + public NoneToolChoiceBehavior() + { + Type = "none"; + } + + /// Initializes a new instance of . + /// The kind of tool-choice strategy. + /// Keeps track of any properties unknown to the library. + internal NoneToolChoiceBehavior(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/OpenAIAgentModel.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/OpenAIAgentModel.Serialization.cs new file mode 100644 index 000000000000..ee7059a9effb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/OpenAIAgentModel.Serialization.cs @@ -0,0 +1,148 @@ +// 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.Projects.OneDP +{ + public partial class OpenAIAgentModel : 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 override 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(OpenAIAgentModel)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + OpenAIAgentModel 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(OpenAIAgentModel)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIAgentModel(document.RootElement, options); + } + + internal static OpenAIAgentModel DeserializeOpenAIAgentModel(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string provider = default; + string endpoint = default; + JSONAny options0 = 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("provider"u8)) + { + provider = property.Value.GetString(); + continue; + } + if (property.NameEquals("endpoint"u8)) + { + endpoint = property.Value.GetString(); + continue; + } + if (property.NameEquals("options"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + options0 = JSONAny.DeserializeJSONAny(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenAIAgentModel(id, provider, endpoint, options0, 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(OpenAIAgentModel)} does not support writing '{options.Format}' format."); + } + } + + OpenAIAgentModel 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 DeserializeOpenAIAgentModel(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIAgentModel)} 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 new OpenAIAgentModel FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIAgentModel(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/OpenAIAgentModel.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/OpenAIAgentModel.cs new file mode 100644 index 000000000000..203e4e198911 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/OpenAIAgentModel.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// A specialized AgentModel for OpenAI-based providers. + public partial class OpenAIAgentModel : AgentModel + { + /// Initializes a new instance of . + /// A unique model or deployment ID for this agent model. + /// The provider-specific options for this OpenAI-based model. + /// or is null. + public OpenAIAgentModel(string id, OpenAIModelOptions options) : base(id) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(options, nameof(options)); + + Provider = "openai"; + } + + /// Initializes a new instance of . + /// A unique model or deployment ID for this agent model. + /// The name of the provider for this model (e.g., 'openai'). + /// An endpoint where the provider can be reached, if applicable. + /// Provider-specific configuration and options (JSON-like structure). + /// Keeps track of any properties unknown to the library. + internal OpenAIAgentModel(string id, string provider, string endpoint, JSONAny options, IDictionary serializedAdditionalRawData) : base(id, provider, endpoint, options, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal OpenAIAgentModel() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/OpenAIModelOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/OpenAIModelOptions.Serialization.cs new file mode 100644 index 000000000000..a5aec6bb2c18 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/OpenAIModelOptions.Serialization.cs @@ -0,0 +1,164 @@ +// 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.Projects.OneDP +{ + public partial class OpenAIModelOptions : 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(OpenAIModelOptions)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Temperature)) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + if (Optional.IsDefined(TopP)) + { + writer.WritePropertyName("topP"u8); + writer.WriteNumberValue(TopP.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 + } + } + } + + OpenAIModelOptions 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(OpenAIModelOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIModelOptions(document.RootElement, options); + } + + internal static OpenAIModelOptions DeserializeOpenAIModelOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + float? temperature = default; + float? topP = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("topP"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + topP = property.Value.GetSingle(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenAIModelOptions(temperature, topP, 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(OpenAIModelOptions)} does not support writing '{options.Format}' format."); + } + } + + OpenAIModelOptions 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 DeserializeOpenAIModelOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIModelOptions)} 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 OpenAIModelOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIModelOptions(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/ai/Azure.AI.Projects.OneDP/src/Generated/OpenAIModelOptions.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/OpenAIModelOptions.cs new file mode 100644 index 000000000000..498506b67e12 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/OpenAIModelOptions.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// A set of provider-specific configuration and behavior options for OpenAI. + public partial class OpenAIModelOptions + { + /// + /// 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 OpenAIModelOptions() + { + } + + /// Initializes a new instance of . + /// + /// The sampling temperature to use that controls the apparent creativity of generated completions. + /// Higher values will make output more random while lower values will make results more focused + /// and deterministic. + /// It is not recommended to modify temperature and topP for the same completions request as the + /// interaction of these two settings is difficult to predict. + /// + /// + /// An alternative to sampling with temperature called nucleus sampling. This value causes the + /// model to consider the results of tokens with the provided probability mass. As an example, a + /// value of 0.15 will cause only the tokens comprising the top 15% of probability mass to be + /// considered. + /// It is not recommended to modify temperature and topP for the same completions request as the + /// interaction of these two settings is difficult to predict. + /// + /// Keeps track of any properties unknown to the library. + internal OpenAIModelOptions(float? temperature, float? topP, IDictionary serializedAdditionalRawData) + { + Temperature = temperature; + TopP = topP; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// The sampling temperature to use that controls the apparent creativity of generated completions. + /// Higher values will make output more random while lower values will make results more focused + /// and deterministic. + /// It is not recommended to modify temperature and topP for the same completions request as the + /// interaction of these two settings is difficult to predict. + /// + public float? Temperature { get; set; } + /// + /// An alternative to sampling with temperature called nucleus sampling. This value causes the + /// model to consider the results of tokens with the provided probability mass. As an example, a + /// value of 0.15 will cause only the tokens comprising the top 15% of probability mass to be + /// considered. + /// It is not recommended to modify temperature and topP for the same completions request as the + /// interaction of these two settings is difficult to predict. + /// + public float? TopP { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/OpenApiToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/OpenApiToolDefinition.Serialization.cs new file mode 100644 index 000000000000..82d197d83a21 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/OpenApiToolDefinition.Serialization.cs @@ -0,0 +1,180 @@ +// 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.Projects.OneDP +{ + public partial class OpenApiToolDefinition : 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 override 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(OpenApiToolDefinition)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("openApiSpec"u8); + writer.WriteStringValue(OpenApiSpec); + } + + OpenApiToolDefinition 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(OpenApiToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiToolDefinition(document.RootElement, options); + } + + internal static OpenApiToolDefinition DeserializeOpenApiToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string description = default; + string openApiSpec = default; + string type = default; + AgentToolOptions options0 = default; + AgentToolDefinitionOverride @override = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("openApiSpec"u8)) + { + openApiSpec = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("options"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + options0 = AgentToolOptions.DeserializeAgentToolOptions(property.Value, options); + continue; + } + if (property.NameEquals("override"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + @override = AgentToolDefinitionOverride.DeserializeAgentToolDefinitionOverride(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenApiToolDefinition( + type, + options0, + @override, + serializedAdditionalRawData, + name, + description, + openApiSpec); + } + + 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(OpenApiToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + OpenApiToolDefinition 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 DeserializeOpenApiToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiToolDefinition)} 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 new OpenApiToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenApiToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/OpenApiToolDefinition.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/OpenApiToolDefinition.cs new file mode 100644 index 000000000000..6d53fa39f87f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/OpenApiToolDefinition.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// A tool definition for an OpenAI-based API described by an OpenAPI specification. + public partial class OpenApiToolDefinition : AgentToolDefinition + { + /// Initializes a new instance of . + /// The name of the OpenAPI-based tool. + /// A string containing the raw OpenAPI specification data. + /// or is null. + public OpenApiToolDefinition(string name, string openApiSpec) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(openApiSpec, nameof(openApiSpec)); + + Type = "OpenAI.OpenApi"; + Name = name; + OpenApiSpec = openApiSpec; + } + + /// Initializes a new instance of . + /// Discriminates the various child 'tool definition' types. + /// Additional options that specify the behavior of this tool (also polymorphic). + /// A set of overrides for the tool's name, description, or parameters. + /// Keeps track of any properties unknown to the library. + /// The name of the OpenAPI-based tool. + /// A description for the tool. + /// A string containing the raw OpenAPI specification data. + internal OpenApiToolDefinition(string type, AgentToolOptions options, AgentToolDefinitionOverride @override, IDictionary serializedAdditionalRawData, string name, string description, string openApiSpec) : base(type, options, @override, serializedAdditionalRawData) + { + Name = name; + Description = description; + OpenApiSpec = openApiSpec; + } + + /// Initializes a new instance of for deserialization. + internal OpenApiToolDefinition() + { + } + + /// The name of the OpenAPI-based tool. + public string Name { get; set; } + /// A description for the tool. + public string Description { get; set; } + /// A string containing the raw OpenAPI specification data. + public string OpenApiSpec { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/PendingUploadRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/PendingUploadRequest.Serialization.cs new file mode 100644 index 000000000000..4c47a8b0d525 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/PendingUploadRequest.Serialization.cs @@ -0,0 +1,164 @@ +// 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.Projects.OneDP +{ + public partial class PendingUploadRequest : 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(PendingUploadRequest)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(PendingUploadId)) + { + writer.WritePropertyName("pendingUploadId"u8); + writer.WriteStringValue(PendingUploadId); + } + if (Optional.IsDefined(ConnectionName)) + { + writer.WritePropertyName("connectionName"u8); + writer.WriteStringValue(ConnectionName); + } + writer.WritePropertyName("pendingUploadType"u8); + writer.WriteStringValue(PendingUploadType.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 + } + } + } + + PendingUploadRequest 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(PendingUploadRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePendingUploadRequest(document.RootElement, options); + } + + internal static PendingUploadRequest DeserializePendingUploadRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string pendingUploadId = default; + string connectionName = default; + PendingUploadType pendingUploadType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("pendingUploadId"u8)) + { + pendingUploadId = property.Value.GetString(); + continue; + } + if (property.NameEquals("connectionName"u8)) + { + connectionName = property.Value.GetString(); + continue; + } + if (property.NameEquals("pendingUploadType"u8)) + { + pendingUploadType = new PendingUploadType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PendingUploadRequest(pendingUploadId, connectionName, pendingUploadType, 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(PendingUploadRequest)} does not support writing '{options.Format}' format."); + } + } + + PendingUploadRequest 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 DeserializePendingUploadRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PendingUploadRequest)} 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 PendingUploadRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePendingUploadRequest(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/ai/Azure.AI.Projects.OneDP/src/Generated/PendingUploadRequest.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/PendingUploadRequest.cs new file mode 100644 index 000000000000..0ee1af04c28b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/PendingUploadRequest.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.Projects.OneDP +{ + /// Represents a request for a pending upload. + public partial class PendingUploadRequest + { + /// + /// 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 PendingUploadRequest() + { + } + + /// Initializes a new instance of . + /// If PendingUploadId is not provided, a random GUID will be used. + /// Name of Azure blob storage connection to use for generating temporary SAS token. + /// TemporaryBlobReference is the only supported type. + /// Keeps track of any properties unknown to the library. + internal PendingUploadRequest(string pendingUploadId, string connectionName, PendingUploadType pendingUploadType, IDictionary serializedAdditionalRawData) + { + PendingUploadId = pendingUploadId; + ConnectionName = connectionName; + PendingUploadType = pendingUploadType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// If PendingUploadId is not provided, a random GUID will be used. + public string PendingUploadId { get; set; } + /// Name of Azure blob storage connection to use for generating temporary SAS token. + public string ConnectionName { get; set; } + /// TemporaryBlobReference is the only supported type. + public PendingUploadType PendingUploadType { get; } = PendingUploadType.TemporaryBlobReference; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/PendingUploadResponse.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/PendingUploadResponse.Serialization.cs new file mode 100644 index 000000000000..ac466ec650a1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/PendingUploadResponse.Serialization.cs @@ -0,0 +1,169 @@ +// 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.Projects.OneDP +{ + public partial class PendingUploadResponse : 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(PendingUploadResponse)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("blobReferenceForConsumption"u8); + writer.WriteObjectValue(BlobReferenceForConsumption, options); + writer.WritePropertyName("pendingUploadId"u8); + writer.WriteStringValue(PendingUploadId); + if (Optional.IsDefined(DatasetVersion)) + { + writer.WritePropertyName("datasetVersion"u8); + writer.WriteStringValue(DatasetVersion); + } + writer.WritePropertyName("pendingUploadType"u8); + writer.WriteStringValue(PendingUploadType.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 + } + } + } + + PendingUploadResponse 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(PendingUploadResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePendingUploadResponse(document.RootElement, options); + } + + internal static PendingUploadResponse DeserializePendingUploadResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BlobReferenceForConsumption blobReferenceForConsumption = default; + string pendingUploadId = default; + string datasetVersion = default; + PendingUploadType pendingUploadType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("blobReferenceForConsumption"u8)) + { + blobReferenceForConsumption = BlobReferenceForConsumption.DeserializeBlobReferenceForConsumption(property.Value, options); + continue; + } + if (property.NameEquals("pendingUploadId"u8)) + { + pendingUploadId = property.Value.GetString(); + continue; + } + if (property.NameEquals("datasetVersion"u8)) + { + datasetVersion = property.Value.GetString(); + continue; + } + if (property.NameEquals("pendingUploadType"u8)) + { + pendingUploadType = new PendingUploadType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PendingUploadResponse(blobReferenceForConsumption, pendingUploadId, datasetVersion, pendingUploadType, 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(PendingUploadResponse)} does not support writing '{options.Format}' format."); + } + } + + PendingUploadResponse 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 DeserializePendingUploadResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PendingUploadResponse)} 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 PendingUploadResponse FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePendingUploadResponse(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/ai/Azure.AI.Projects.OneDP/src/Generated/PendingUploadResponse.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/PendingUploadResponse.cs new file mode 100644 index 000000000000..5acdf2aadac5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/PendingUploadResponse.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; + +namespace Azure.AI.Projects.OneDP +{ + /// Represents the response for a pending upload request. + public partial class PendingUploadResponse + { + /// + /// 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 . + /// Container-level read, write, list SAS. + /// ID for this upload request. + /// or is null. + internal PendingUploadResponse(BlobReferenceForConsumption blobReferenceForConsumption, string pendingUploadId) + { + Argument.AssertNotNull(blobReferenceForConsumption, nameof(blobReferenceForConsumption)); + Argument.AssertNotNull(pendingUploadId, nameof(pendingUploadId)); + + BlobReferenceForConsumption = blobReferenceForConsumption; + PendingUploadId = pendingUploadId; + } + + /// Initializes a new instance of . + /// Container-level read, write, list SAS. + /// ID for this upload request. + /// Version of dataset to be created if user did not specify version when initially creating upload. + /// TemporaryBlobReference is the only supported type. + /// Keeps track of any properties unknown to the library. + internal PendingUploadResponse(BlobReferenceForConsumption blobReferenceForConsumption, string pendingUploadId, string datasetVersion, PendingUploadType pendingUploadType, IDictionary serializedAdditionalRawData) + { + BlobReferenceForConsumption = blobReferenceForConsumption; + PendingUploadId = pendingUploadId; + DatasetVersion = datasetVersion; + PendingUploadType = pendingUploadType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal PendingUploadResponse() + { + } + + /// Container-level read, write, list SAS. + public BlobReferenceForConsumption BlobReferenceForConsumption { get; } + /// ID for this upload request. + public string PendingUploadId { get; } + /// Version of dataset to be created if user did not specify version when initially creating upload. + public string DatasetVersion { get; } + /// TemporaryBlobReference is the only supported type. + public PendingUploadType PendingUploadType { get; } = PendingUploadType.TemporaryBlobReference; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/PendingUploadType.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/PendingUploadType.cs new file mode 100644 index 000000000000..e3ce87ba0254 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/PendingUploadType.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.Projects.OneDP +{ + /// The type of pending upload. + public readonly partial struct PendingUploadType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PendingUploadType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoneValue = "None"; + private const string TemporaryBlobReferenceValue = "TemporaryBlobReference"; + + /// No pending upload. + public static PendingUploadType None { get; } = new PendingUploadType(NoneValue); + /// Temporary Blob Reference is the only supported type. + public static PendingUploadType TemporaryBlobReference { get; } = new PendingUploadType(TemporaryBlobReferenceValue); + /// Determines if two values are the same. + public static bool operator ==(PendingUploadType left, PendingUploadType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PendingUploadType left, PendingUploadType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PendingUploadType(string value) => new PendingUploadType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PendingUploadType other && Equals(other); + /// + public bool Equals(PendingUploadType 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/ai/Azure.AI.Projects.OneDP/src/Generated/RefusalContent.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RefusalContent.Serialization.cs new file mode 100644 index 000000000000..fc6d24e995a6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RefusalContent.Serialization.cs @@ -0,0 +1,134 @@ +// 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.Projects.OneDP +{ + public partial class RefusalContent : 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 override 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(RefusalContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("refusal"u8); + writer.WriteStringValue(Refusal); + } + + RefusalContent 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(RefusalContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRefusalContent(document.RootElement, options); + } + + internal static RefusalContent DeserializeRefusalContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string refusal = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("refusal"u8)) + { + refusal = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RefusalContent(type, serializedAdditionalRawData, refusal); + } + + 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(RefusalContent)} does not support writing '{options.Format}' format."); + } + } + + RefusalContent 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 DeserializeRefusalContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RefusalContent)} 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 new RefusalContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRefusalContent(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RefusalContent.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RefusalContent.cs new file mode 100644 index 000000000000..4f5c6ea0b420 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RefusalContent.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// A structured chat content item containing model refusal information for a structured outputs request. + public partial class RefusalContent : AIContent + { + /// Initializes a new instance of . + /// Reason for refusal. + /// is null. + public RefusalContent(string refusal) + { + Argument.AssertNotNull(refusal, nameof(refusal)); + + Type = "refusal"; + Refusal = refusal; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// Reason for refusal. + internal RefusalContent(string type, IDictionary serializedAdditionalRawData, string refusal) : base(type, serializedAdditionalRawData) + { + Refusal = refusal; + } + + /// Initializes a new instance of for deserialization. + internal RefusalContent() + { + } + + /// Reason for refusal. + public string Refusal { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RequiredToolChoiceBehavior.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RequiredToolChoiceBehavior.Serialization.cs new file mode 100644 index 000000000000..ab991d1c7e68 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RequiredToolChoiceBehavior.Serialization.cs @@ -0,0 +1,144 @@ +// 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.Projects.OneDP +{ + public partial class RequiredToolChoiceBehavior : 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 override 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(RequiredToolChoiceBehavior)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("toolNames"u8); + writer.WriteStartArray(); + foreach (var item in ToolNames) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + + RequiredToolChoiceBehavior 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(RequiredToolChoiceBehavior)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRequiredToolChoiceBehavior(document.RootElement, options); + } + + internal static RequiredToolChoiceBehavior DeserializeRequiredToolChoiceBehavior(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList toolNames = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("toolNames"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + toolNames = array; + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RequiredToolChoiceBehavior(type, serializedAdditionalRawData, toolNames); + } + + 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(RequiredToolChoiceBehavior)} does not support writing '{options.Format}' format."); + } + } + + RequiredToolChoiceBehavior 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 DeserializeRequiredToolChoiceBehavior(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RequiredToolChoiceBehavior)} 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 new RequiredToolChoiceBehavior FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRequiredToolChoiceBehavior(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RequiredToolChoiceBehavior.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RequiredToolChoiceBehavior.cs new file mode 100644 index 000000000000..b325189c06cf --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RequiredToolChoiceBehavior.cs @@ -0,0 +1,45 @@ +// 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.Projects.OneDP +{ + /// Behavior specifying that the agent must always use the listed tools. + public partial class RequiredToolChoiceBehavior : ToolChoiceBehavior + { + /// Initializes a new instance of . + /// The tool names that the agent must use. + /// is null. + public RequiredToolChoiceBehavior(IEnumerable toolNames) + { + Argument.AssertNotNull(toolNames, nameof(toolNames)); + + Type = "required"; + ToolNames = toolNames.ToList(); + } + + /// Initializes a new instance of . + /// The kind of tool-choice strategy. + /// Keeps track of any properties unknown to the library. + /// The tool names that the agent must use. + internal RequiredToolChoiceBehavior(string type, IDictionary serializedAdditionalRawData, IList toolNames) : base(type, serializedAdditionalRawData) + { + ToolNames = toolNames; + } + + /// Initializes a new instance of for deserialization. + internal RequiredToolChoiceBehavior() + { + } + + /// The tool names that the agent must use. + public IList ToolNames { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Run.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Run.Serialization.cs new file mode 100644 index 000000000000..6199382fe2cf --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Run.Serialization.cs @@ -0,0 +1,255 @@ +// 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.Projects.OneDP +{ + public partial class Run : 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(Run)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("runId"u8); + writer.WriteStringValue(RunId); + } + writer.WritePropertyName("createdAt"u8); + writer.WriteNumberValue(CreatedAt); + writer.WritePropertyName("completedAt"u8); + writer.WriteNumberValue(CompletedAt); + writer.WritePropertyName("runInputs"u8); + writer.WriteObjectValue(RunInputs, options); + if (Optional.IsDefined(UserId)) + { + writer.WritePropertyName("userId"u8); + writer.WriteStringValue(UserId); + } + if (Optional.IsDefined(Store)) + { + writer.WritePropertyName("store"u8); + writer.WriteBooleanValue(Store.Value); + } + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("output"u8); + writer.WriteStartArray(); + foreach (var item in Output) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("usage"u8); + writer.WriteObjectValue(Usage, options); + if (Optional.IsDefined(IncompleteDetails)) + { + writer.WritePropertyName("incompleteDetails"u8); + writer.WriteObjectValue(IncompleteDetails, 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 + } + } + } + + Run 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(Run)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRun(document.RootElement, options); + } + + internal static Run DeserializeRun(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string runId = default; + long createdAt = default; + long completedAt = default; + RunInputs runInputs = default; + string userId = default; + bool? store = default; + RunOutputsStatus status = default; + IReadOnlyList output = default; + CompletionUsage usage = default; + RunIncompleteDetails incompleteDetails = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("runId"u8)) + { + runId = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdAt"u8)) + { + createdAt = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("completedAt"u8)) + { + completedAt = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("runInputs"u8)) + { + runInputs = RunInputs.DeserializeRunInputs(property.Value, options); + continue; + } + if (property.NameEquals("userId"u8)) + { + userId = property.Value.GetString(); + continue; + } + if (property.NameEquals("store"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + store = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new RunOutputsStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("output"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ChatMessage.DeserializeChatMessage(item, options)); + } + output = array; + continue; + } + if (property.NameEquals("usage"u8)) + { + usage = CompletionUsage.DeserializeCompletionUsage(property.Value, options); + continue; + } + if (property.NameEquals("incompleteDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + incompleteDetails = RunIncompleteDetails.DeserializeRunIncompleteDetails(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Run( + runId, + createdAt, + completedAt, + runInputs, + userId, + store, + status, + output, + usage, + incompleteDetails, + 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(Run)} does not support writing '{options.Format}' format."); + } + } + + Run 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 DeserializeRun(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Run)} 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 Run FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRun(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/ai/Azure.AI.Projects.OneDP/src/Generated/Run.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Run.cs new file mode 100644 index 000000000000..42968426adfe --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Run.cs @@ -0,0 +1,136 @@ +// 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.Projects.OneDP +{ + /// An agent-generated run record, including both the requested inputs and the final outputs. + public partial class Run + { + /// + /// 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 . + /// Timestamp when the run was initiated (Unix time). + /// Timestamp when the run finished processing (Unix time). + /// The inputs that were used to start this run. + /// Final status of the run request. Known values: 'inProgress', 'incomplete', 'cancelled', 'failed', 'completed' - or custom string. + /// + /// List of output messages generated by the agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// Token usage details for this run. + /// , or is null. + internal Run(long createdAt, long completedAt, RunInputs runInputs, RunOutputsStatus status, IEnumerable output, CompletionUsage usage) + { + Argument.AssertNotNull(runInputs, nameof(runInputs)); + Argument.AssertNotNull(output, nameof(output)); + Argument.AssertNotNull(usage, nameof(usage)); + + CreatedAt = createdAt; + CompletedAt = completedAt; + RunInputs = runInputs; + Status = status; + Output = output.ToList(); + Usage = usage; + } + + /// Initializes a new instance of . + /// Unique identifier for this run. + /// Timestamp when the run was initiated (Unix time). + /// Timestamp when the run finished processing (Unix time). + /// The inputs that were used to start this run. + /// Identifier for the user making the request. + /// Flag indicating whether to store the run and associated messages. + /// Final status of the run request. Known values: 'inProgress', 'incomplete', 'cancelled', 'failed', 'completed' - or custom string. + /// + /// List of output messages generated by the agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// Token usage details for this run. + /// Details about why the response is incomplete, if applicable. + /// Keeps track of any properties unknown to the library. + internal Run(string runId, long createdAt, long completedAt, RunInputs runInputs, string userId, bool? store, RunOutputsStatus status, IReadOnlyList output, CompletionUsage usage, RunIncompleteDetails incompleteDetails, IDictionary serializedAdditionalRawData) + { + RunId = runId; + CreatedAt = createdAt; + CompletedAt = completedAt; + RunInputs = runInputs; + UserId = userId; + Store = store; + Status = status; + Output = output; + Usage = usage; + IncompleteDetails = incompleteDetails; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Run() + { + } + + /// Unique identifier for this run. + public string RunId { get; } + /// Timestamp when the run was initiated (Unix time). + public long CreatedAt { get; } + /// Timestamp when the run finished processing (Unix time). + public long CompletedAt { get; } + /// The inputs that were used to start this run. + public RunInputs RunInputs { get; } + /// Identifier for the user making the request. + public string UserId { get; } + /// Flag indicating whether to store the run and associated messages. + public bool? Store { get; } + /// Final status of the run request. Known values: 'inProgress', 'incomplete', 'cancelled', 'failed', 'completed' - or custom string. + public RunOutputsStatus Status { get; } + /// + /// List of output messages generated by the agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + public IReadOnlyList Output { get; } + /// Token usage details for this run. + public CompletionUsage Usage { get; } + /// Details about why the response is incomplete, if applicable. + public RunIncompleteDetails IncompleteDetails { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunIncompleteDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunIncompleteDetails.Serialization.cs new file mode 100644 index 000000000000..21ea0e7cb788 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunIncompleteDetails.Serialization.cs @@ -0,0 +1,142 @@ +// 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.Projects.OneDP +{ + public partial class RunIncompleteDetails : 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(RunIncompleteDetails)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(Reason); + 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 + } + } + } + + RunIncompleteDetails 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(RunIncompleteDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunIncompleteDetails(document.RootElement, options); + } + + internal static RunIncompleteDetails DeserializeRunIncompleteDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string reason = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("reason"u8)) + { + reason = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunIncompleteDetails(reason, 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(RunIncompleteDetails)} does not support writing '{options.Format}' format."); + } + } + + RunIncompleteDetails 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 DeserializeRunIncompleteDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunIncompleteDetails)} 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 RunIncompleteDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunIncompleteDetails(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/ai/Azure.AI.Projects.OneDP/src/Generated/RunIncompleteDetails.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunIncompleteDetails.cs new file mode 100644 index 000000000000..7ffc56e7ca44 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunIncompleteDetails.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.Projects.OneDP +{ + /// The RunIncompleteDetails. + public partial class RunIncompleteDetails + { + /// + /// 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 . + /// + /// is null. + internal RunIncompleteDetails(string reason) + { + Argument.AssertNotNull(reason, nameof(reason)); + + Reason = reason; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal RunIncompleteDetails(string reason, IDictionary serializedAdditionalRawData) + { + Reason = reason; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunIncompleteDetails() + { + } + + /// Gets the reason. + public string Reason { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunInputs.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunInputs.Serialization.cs new file mode 100644 index 000000000000..5df34f3388fa --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunInputs.Serialization.cs @@ -0,0 +1,249 @@ +// 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.Projects.OneDP +{ + public partial class RunInputs : 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(RunInputs)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(AgentId)) + { + writer.WritePropertyName("agentId"u8); + writer.WriteStringValue(AgentId); + } + writer.WritePropertyName("input"u8); + writer.WriteStartArray(); + foreach (var item in Input) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(ConversationId)) + { + writer.WritePropertyName("conversationId"u8); + writer.WriteStringValue(ConversationId); + } + 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(Options)) + { + writer.WritePropertyName("options"u8); + writer.WriteObjectValue(Options, options); + } + if (Optional.IsDefined(UserId)) + { + writer.WritePropertyName("userId"u8); + writer.WriteStringValue(UserId); + } + if (Optional.IsDefined(AgentConfiguration)) + { + writer.WritePropertyName("agentConfiguration"u8); + writer.WriteObjectValue(AgentConfiguration, 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 + } + } + } + + RunInputs 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(RunInputs)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunInputs(document.RootElement, options); + } + + internal static RunInputs DeserializeRunInputs(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string agentId = default; + IReadOnlyList input = default; + string conversationId = default; + IReadOnlyDictionary metadata = default; + RunOptions options0 = default; + string userId = default; + AgentConfigurationOptions agentConfiguration = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("agentId"u8)) + { + agentId = property.Value.GetString(); + continue; + } + if (property.NameEquals("input"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ChatMessage.DeserializeChatMessage(item, options)); + } + input = array; + continue; + } + if (property.NameEquals("conversationId"u8)) + { + conversationId = 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("options"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + options0 = RunOptions.DeserializeRunOptions(property.Value, options); + continue; + } + if (property.NameEquals("userId"u8)) + { + userId = property.Value.GetString(); + continue; + } + if (property.NameEquals("agentConfiguration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + agentConfiguration = AgentConfigurationOptions.DeserializeAgentConfigurationOptions(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunInputs( + agentId, + input, + conversationId, + metadata ?? new ChangeTrackingDictionary(), + options0, + userId, + agentConfiguration, + 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(RunInputs)} does not support writing '{options.Format}' format."); + } + } + + RunInputs 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 DeserializeRunInputs(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunInputs)} 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 RunInputs FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunInputs(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/ai/Azure.AI.Projects.OneDP/src/Generated/RunInputs.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunInputs.cs new file mode 100644 index 000000000000..56dcd281357d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunInputs.cs @@ -0,0 +1,113 @@ +// 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.Projects.OneDP +{ + /// Parameters for creating a new run request. + public partial class RunInputs + { + /// + /// 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 list of input messages for the run. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// is null. + internal RunInputs(IEnumerable input) + { + Argument.AssertNotNull(input, nameof(input)); + + Input = input.ToList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Unique identifier for the agent responsible for the run. This is optional (not needeed) when doing a run using ephemeral agent. + /// + /// The list of input messages for the run. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// Optional identifier for an existing conversation. + /// Optional metadata associated with the run request. + /// Optional configuration for run generation. + /// Identifier for the user making the request. + /// The agent configuration when not using a previously created agent. + /// Keeps track of any properties unknown to the library. + internal RunInputs(string agentId, IReadOnlyList input, string conversationId, IReadOnlyDictionary metadata, RunOptions options, string userId, AgentConfigurationOptions agentConfiguration, IDictionary serializedAdditionalRawData) + { + AgentId = agentId; + Input = input; + ConversationId = conversationId; + Metadata = metadata; + Options = options; + UserId = userId; + AgentConfiguration = agentConfiguration; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunInputs() + { + } + + /// Unique identifier for the agent responsible for the run. This is optional (not needeed) when doing a run using ephemeral agent. + public string AgentId { get; } + /// + /// The list of input messages for the run. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + public IReadOnlyList Input { get; } + /// Optional identifier for an existing conversation. + public string ConversationId { get; } + /// Optional metadata associated with the run request. + public IReadOnlyDictionary Metadata { get; } + /// Optional configuration for run generation. + public RunOptions Options { get; } + /// Identifier for the user making the request. + public string UserId { get; } + /// The agent configuration when not using a previously created agent. + public AgentConfigurationOptions AgentConfiguration { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunOptions.Serialization.cs new file mode 100644 index 000000000000..6e84be5927e1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunOptions.Serialization.cs @@ -0,0 +1,149 @@ +// 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.Projects.OneDP +{ + public partial class RunOptions : 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(RunOptions)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(TruncationStrategy)) + { + writer.WritePropertyName("truncationStrategy"u8); + writer.WriteObjectValue(TruncationStrategy, 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 + } + } + } + + RunOptions 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(RunOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunOptions(document.RootElement, options); + } + + internal static RunOptions DeserializeRunOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TruncationStrategy truncationStrategy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("truncationStrategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + truncationStrategy = TruncationStrategy.DeserializeTruncationStrategy(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunOptions(truncationStrategy, 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(RunOptions)} does not support writing '{options.Format}' format."); + } + } + + RunOptions 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 DeserializeRunOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunOptions)} 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 RunOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunOptions(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/ai/Azure.AI.Projects.OneDP/src/Generated/RunOptions.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunOptions.cs new file mode 100644 index 000000000000..bf4904dccbad --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunOptions.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.Projects.OneDP +{ + /// Represents advanced options for controlling agent runs. + public partial class RunOptions + { + /// + /// 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 RunOptions() + { + } + + /// Initializes a new instance of . + /// Strategy for truncating messages when input exceeds model limits. + /// Keeps track of any properties unknown to the library. + internal RunOptions(TruncationStrategy truncationStrategy, IDictionary serializedAdditionalRawData) + { + TruncationStrategy = truncationStrategy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Strategy for truncating messages when input exceeds model limits. + public TruncationStrategy TruncationStrategy { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunOutputsStatus.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunOutputsStatus.cs new file mode 100644 index 000000000000..ecc98113d41b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunOutputsStatus.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.Projects.OneDP +{ + /// Known status values for a run, plus a fallback string for unrecognized statuses. + public readonly partial struct RunOutputsStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RunOutputsStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InProgressValue = "inProgress"; + private const string IncompleteValue = "incomplete"; + private const string CancelledValue = "cancelled"; + private const string FailedValue = "failed"; + private const string CompletedValue = "completed"; + + /// The run is ongoing. + public static RunOutputsStatus InProgress { get; } = new RunOutputsStatus(InProgressValue); + /// The run did not produce a complete output. + public static RunOutputsStatus Incomplete { get; } = new RunOutputsStatus(IncompleteValue); + /// The run was canceled. + public static RunOutputsStatus Cancelled { get; } = new RunOutputsStatus(CancelledValue); + /// The run failed. + public static RunOutputsStatus Failed { get; } = new RunOutputsStatus(FailedValue); + /// The run completed successfully. + public static RunOutputsStatus Completed { get; } = new RunOutputsStatus(CompletedValue); + /// Determines if two values are the same. + public static bool operator ==(RunOutputsStatus left, RunOutputsStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RunOutputsStatus left, RunOutputsStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator RunOutputsStatus(string value) => new RunOutputsStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunOutputsStatus other && Equals(other); + /// + public bool Equals(RunOutputsStatus 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/ai/Azure.AI.Projects.OneDP/src/Generated/RunRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunRequest.Serialization.cs new file mode 100644 index 000000000000..38fdeab97174 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunRequest.Serialization.cs @@ -0,0 +1,249 @@ +// 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.Projects.OneDP +{ + internal partial class RunRequest : 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(RunRequest)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(AgentId)) + { + writer.WritePropertyName("agentId"u8); + writer.WriteStringValue(AgentId); + } + writer.WritePropertyName("input"u8); + writer.WriteStartArray(); + foreach (var item in Input) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(ConversationId)) + { + writer.WritePropertyName("conversationId"u8); + writer.WriteStringValue(ConversationId); + } + 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(Options)) + { + writer.WritePropertyName("options"u8); + writer.WriteObjectValue(Options, options); + } + if (Optional.IsDefined(UserId)) + { + writer.WritePropertyName("userId"u8); + writer.WriteStringValue(UserId); + } + if (Optional.IsDefined(AgentConfiguration)) + { + writer.WritePropertyName("agentConfiguration"u8); + writer.WriteObjectValue(AgentConfiguration, 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 + } + } + } + + RunRequest 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(RunRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunRequest(document.RootElement, options); + } + + internal static RunRequest DeserializeRunRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string agentId = default; + IReadOnlyList input = default; + string conversationId = default; + IReadOnlyDictionary metadata = default; + RunOptions options0 = default; + string userId = default; + AgentConfigurationOptions agentConfiguration = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("agentId"u8)) + { + agentId = property.Value.GetString(); + continue; + } + if (property.NameEquals("input"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ChatMessage.DeserializeChatMessage(item, options)); + } + input = array; + continue; + } + if (property.NameEquals("conversationId"u8)) + { + conversationId = 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("options"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + options0 = RunOptions.DeserializeRunOptions(property.Value, options); + continue; + } + if (property.NameEquals("userId"u8)) + { + userId = property.Value.GetString(); + continue; + } + if (property.NameEquals("agentConfiguration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + agentConfiguration = AgentConfigurationOptions.DeserializeAgentConfigurationOptions(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunRequest( + agentId, + input, + conversationId, + metadata ?? new ChangeTrackingDictionary(), + options0, + userId, + agentConfiguration, + 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(RunRequest)} does not support writing '{options.Format}' format."); + } + } + + RunRequest 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 DeserializeRunRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunRequest)} 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 RunRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunRequest(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/ai/Azure.AI.Projects.OneDP/src/Generated/RunRequest.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunRequest.cs new file mode 100644 index 000000000000..5d2e8b3db829 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/RunRequest.cs @@ -0,0 +1,113 @@ +// 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.Projects.OneDP +{ + /// The RunRequest. + internal partial class RunRequest + { + /// + /// 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 list of input messages for the run. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// is null. + internal RunRequest(IEnumerable input) + { + Argument.AssertNotNull(input, nameof(input)); + + Input = input.ToList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Unique identifier for the agent responsible for the run. This is optional (not needeed) when doing a run using ephemeral agent. + /// + /// The list of input messages for the run. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// Optional identifier for an existing conversation. + /// Optional metadata associated with the run request. + /// Optional configuration for run generation. + /// Identifier for the user making the request. + /// The agent configuration when not using a previously created agent. + /// Keeps track of any properties unknown to the library. + internal RunRequest(string agentId, IReadOnlyList input, string conversationId, IReadOnlyDictionary metadata, RunOptions options, string userId, AgentConfigurationOptions agentConfiguration, IDictionary serializedAdditionalRawData) + { + AgentId = agentId; + Input = input; + ConversationId = conversationId; + Metadata = metadata; + Options = options; + UserId = userId; + AgentConfiguration = agentConfiguration; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunRequest() + { + } + + /// Unique identifier for the agent responsible for the run. This is optional (not needeed) when doing a run using ephemeral agent. + public string AgentId { get; } + /// + /// The list of input messages for the run. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + public IReadOnlyList Input { get; } + /// Optional identifier for an existing conversation. + public string ConversationId { get; } + /// Optional metadata associated with the run request. + public IReadOnlyDictionary Metadata { get; } + /// Optional configuration for run generation. + public RunOptions Options { get; } + /// Identifier for the user making the request. + public string UserId { get; } + /// The agent configuration when not using a previously created agent. + public AgentConfigurationOptions AgentConfiguration { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/SasCredential.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/SasCredential.Serialization.cs new file mode 100644 index 000000000000..32960743ffc7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/SasCredential.Serialization.cs @@ -0,0 +1,137 @@ +// 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.Projects.OneDP +{ + public partial class SasCredential : 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 override 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(SasCredential)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (options.Format != "W") + { + writer.WritePropertyName("sasToken"u8); + writer.WriteStringValue(SasToken); + } + } + + SasCredential 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(SasCredential)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSasCredential(document.RootElement, options); + } + + internal static SasCredential DeserializeSasCredential(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string sasToken = default; + CredentialType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sasToken"u8)) + { + sasToken = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new CredentialType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SasCredential(type, serializedAdditionalRawData, sasToken); + } + + 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(SasCredential)} does not support writing '{options.Format}' format."); + } + } + + SasCredential 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 DeserializeSasCredential(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SasCredential)} 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 new SasCredential FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSasCredential(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/SasCredential.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/SasCredential.cs new file mode 100644 index 000000000000..ee731062f784 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/SasCredential.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// SAS Credential definition. + public partial class SasCredential : BaseCredential + { + /// Initializes a new instance of . + internal SasCredential() + { + Type = CredentialType.SAS; + } + + /// Initializes a new instance of . + /// Type of credential. Possible values are: AAD, SAS, ApiKey. + /// Keeps track of any properties unknown to the library. + /// SAS Token. + internal SasCredential(CredentialType type, IDictionary serializedAdditionalRawData, string sasToken) : base(type, serializedAdditionalRawData) + { + SasToken = sasToken; + } + + /// SAS Token. + public string SasToken { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ServicePatterns.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ServicePatterns.cs new file mode 100644 index 000000000000..4bb9fb967926 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ServicePatterns.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Projects.OneDP +{ + // Data plane generated sub-client. + /// The ServicePatterns sub-client. + public partial class ServicePatterns + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + 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 ServicePatterns for mocking. + protected ServicePatterns() + { + } + + /// Initializes a new instance of ServicePatterns. + /// 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. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + internal ServicePatterns(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + } + + private ServicePatternsBuildingBlocks _cachedServicePatternsBuildingBlocks; + + /// Initializes a new instance of ServicePatternsBuildingBlocks. + public virtual ServicePatternsBuildingBlocks GetServicePatternsBuildingBlocksClient() + { + return Volatile.Read(ref _cachedServicePatternsBuildingBlocks) ?? Interlocked.CompareExchange(ref _cachedServicePatternsBuildingBlocks, new ServicePatternsBuildingBlocks(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint), null) ?? _cachedServicePatternsBuildingBlocks; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ServicePatternsBuildingBlocks.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ServicePatternsBuildingBlocks.cs new file mode 100644 index 000000000000..9e028068c8fd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ServicePatternsBuildingBlocks.cs @@ -0,0 +1,52 @@ +// 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.Projects.OneDP +{ + // Data plane generated sub-client. + /// The ServicePatternsBuildingBlocks sub-client. + public partial class ServicePatternsBuildingBlocks + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + 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 ServicePatternsBuildingBlocks for mocking. + protected ServicePatternsBuildingBlocks() + { + } + + /// Initializes a new instance of ServicePatternsBuildingBlocks. + /// 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. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + internal ServicePatternsBuildingBlocks(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Sku.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Sku.Serialization.cs new file mode 100644 index 000000000000..f7c2d3e3e6dd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Sku.Serialization.cs @@ -0,0 +1,180 @@ +// 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.Projects.OneDP +{ + public partial class Sku : 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(Sku)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("capacity"u8); + writer.WriteNumberValue(Capacity); + writer.WritePropertyName("family"u8); + writer.WriteStringValue(Family); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("size"u8); + writer.WriteStringValue(Size); + writer.WritePropertyName("tier"u8); + writer.WriteStringValue(Tier); + 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 + } + } + } + + Sku 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(Sku)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSku(document.RootElement, options); + } + + internal static Sku DeserializeSku(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + long capacity = default; + string family = default; + string name = default; + string size = default; + string tier = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("capacity"u8)) + { + capacity = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("family"u8)) + { + family = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("size"u8)) + { + size = property.Value.GetString(); + continue; + } + if (property.NameEquals("tier"u8)) + { + tier = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Sku( + capacity, + family, + name, + size, + tier, + 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(Sku)} does not support writing '{options.Format}' format."); + } + } + + Sku 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 DeserializeSku(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Sku)} 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 Sku FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSku(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/ai/Azure.AI.Projects.OneDP/src/Generated/Sku.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Sku.cs new file mode 100644 index 000000000000..637332bee33d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/Sku.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Sku information. + public partial class Sku + { + /// + /// 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 . + /// Sku capacity. + /// Sku family. + /// Sku name. + /// Sku size. + /// Sku tier. + /// , , or is null. + internal Sku(long capacity, string family, string name, string size, string tier) + { + Argument.AssertNotNull(family, nameof(family)); + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(size, nameof(size)); + Argument.AssertNotNull(tier, nameof(tier)); + + Capacity = capacity; + Family = family; + Name = name; + Size = size; + Tier = tier; + } + + /// Initializes a new instance of . + /// Sku capacity. + /// Sku family. + /// Sku name. + /// Sku size. + /// Sku tier. + /// Keeps track of any properties unknown to the library. + internal Sku(long capacity, string family, string name, string size, string tier, IDictionary serializedAdditionalRawData) + { + Capacity = capacity; + Family = family; + Name = name; + Size = size; + Tier = tier; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Sku() + { + } + + /// Sku capacity. + public long Capacity { get; } + /// Sku family. + public string Family { get; } + /// Sku name. + public string Name { get; } + /// Sku size. + public string Size { get; } + /// Sku tier. + public string Tier { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/StartPendingUploadAutoIncrementRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/StartPendingUploadAutoIncrementRequest.Serialization.cs new file mode 100644 index 000000000000..58623f310dda --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/StartPendingUploadAutoIncrementRequest.Serialization.cs @@ -0,0 +1,164 @@ +// 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.Projects.OneDP +{ + internal partial class StartPendingUploadAutoIncrementRequest : 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(StartPendingUploadAutoIncrementRequest)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(PendingUploadId)) + { + writer.WritePropertyName("pendingUploadId"u8); + writer.WriteStringValue(PendingUploadId); + } + if (Optional.IsDefined(ConnectionName)) + { + writer.WritePropertyName("connectionName"u8); + writer.WriteStringValue(ConnectionName); + } + writer.WritePropertyName("pendingUploadType"u8); + writer.WriteStringValue(PendingUploadType.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 + } + } + } + + StartPendingUploadAutoIncrementRequest 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(StartPendingUploadAutoIncrementRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStartPendingUploadAutoIncrementRequest(document.RootElement, options); + } + + internal static StartPendingUploadAutoIncrementRequest DeserializeStartPendingUploadAutoIncrementRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string pendingUploadId = default; + string connectionName = default; + PendingUploadType pendingUploadType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("pendingUploadId"u8)) + { + pendingUploadId = property.Value.GetString(); + continue; + } + if (property.NameEquals("connectionName"u8)) + { + connectionName = property.Value.GetString(); + continue; + } + if (property.NameEquals("pendingUploadType"u8)) + { + pendingUploadType = new PendingUploadType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new StartPendingUploadAutoIncrementRequest(pendingUploadId, connectionName, pendingUploadType, 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(StartPendingUploadAutoIncrementRequest)} does not support writing '{options.Format}' format."); + } + } + + StartPendingUploadAutoIncrementRequest 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 DeserializeStartPendingUploadAutoIncrementRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StartPendingUploadAutoIncrementRequest)} 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 StartPendingUploadAutoIncrementRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeStartPendingUploadAutoIncrementRequest(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/ai/Azure.AI.Projects.OneDP/src/Generated/StartPendingUploadAutoIncrementRequest.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/StartPendingUploadAutoIncrementRequest.cs new file mode 100644 index 000000000000..78694db4808c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/StartPendingUploadAutoIncrementRequest.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.Projects.OneDP +{ + /// The StartPendingUploadAutoIncrementRequest. + internal partial class StartPendingUploadAutoIncrementRequest + { + /// + /// 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 StartPendingUploadAutoIncrementRequest() + { + } + + /// Initializes a new instance of . + /// If PendingUploadId is not provided, a random GUID will be used. + /// Name of Azure blob storage connection to use for generating temporary SAS token. + /// TemporaryBlobReference is the only supported type. + /// Keeps track of any properties unknown to the library. + internal StartPendingUploadAutoIncrementRequest(string pendingUploadId, string connectionName, PendingUploadType pendingUploadType, IDictionary serializedAdditionalRawData) + { + PendingUploadId = pendingUploadId; + ConnectionName = connectionName; + PendingUploadType = pendingUploadType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// If PendingUploadId is not provided, a random GUID will be used. + public string PendingUploadId { get; } + /// Name of Azure blob storage connection to use for generating temporary SAS token. + public string ConnectionName { get; } + /// TemporaryBlobReference is the only supported type. + public PendingUploadType PendingUploadType { get; } = PendingUploadType.TemporaryBlobReference; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/StreamRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/StreamRequest.Serialization.cs new file mode 100644 index 000000000000..4c7c25593296 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/StreamRequest.Serialization.cs @@ -0,0 +1,249 @@ +// 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.Projects.OneDP +{ + internal partial class StreamRequest : 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(StreamRequest)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(AgentId)) + { + writer.WritePropertyName("agentId"u8); + writer.WriteStringValue(AgentId); + } + writer.WritePropertyName("input"u8); + writer.WriteStartArray(); + foreach (var item in Input) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(ConversationId)) + { + writer.WritePropertyName("conversationId"u8); + writer.WriteStringValue(ConversationId); + } + 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(Options)) + { + writer.WritePropertyName("options"u8); + writer.WriteObjectValue(Options, options); + } + if (Optional.IsDefined(UserId)) + { + writer.WritePropertyName("userId"u8); + writer.WriteStringValue(UserId); + } + if (Optional.IsDefined(AgentConfiguration)) + { + writer.WritePropertyName("agentConfiguration"u8); + writer.WriteObjectValue(AgentConfiguration, 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 + } + } + } + + StreamRequest 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(StreamRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStreamRequest(document.RootElement, options); + } + + internal static StreamRequest DeserializeStreamRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string agentId = default; + IReadOnlyList input = default; + string conversationId = default; + IReadOnlyDictionary metadata = default; + RunOptions options0 = default; + string userId = default; + AgentConfigurationOptions agentConfiguration = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("agentId"u8)) + { + agentId = property.Value.GetString(); + continue; + } + if (property.NameEquals("input"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ChatMessage.DeserializeChatMessage(item, options)); + } + input = array; + continue; + } + if (property.NameEquals("conversationId"u8)) + { + conversationId = 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("options"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + options0 = RunOptions.DeserializeRunOptions(property.Value, options); + continue; + } + if (property.NameEquals("userId"u8)) + { + userId = property.Value.GetString(); + continue; + } + if (property.NameEquals("agentConfiguration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + agentConfiguration = AgentConfigurationOptions.DeserializeAgentConfigurationOptions(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new StreamRequest( + agentId, + input, + conversationId, + metadata ?? new ChangeTrackingDictionary(), + options0, + userId, + agentConfiguration, + 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(StreamRequest)} does not support writing '{options.Format}' format."); + } + } + + StreamRequest 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 DeserializeStreamRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StreamRequest)} 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 StreamRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeStreamRequest(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/ai/Azure.AI.Projects.OneDP/src/Generated/StreamRequest.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/StreamRequest.cs new file mode 100644 index 000000000000..ceb6ab759698 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/StreamRequest.cs @@ -0,0 +1,113 @@ +// 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.Projects.OneDP +{ + /// The StreamRequest. + internal partial class StreamRequest + { + /// + /// 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 list of input messages for the run. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// is null. + internal StreamRequest(IEnumerable input) + { + Argument.AssertNotNull(input, nameof(input)); + + Input = input.ToList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Unique identifier for the agent responsible for the run. This is optional (not needeed) when doing a run using ephemeral agent. + /// + /// The list of input messages for the run. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// Optional identifier for an existing conversation. + /// Optional metadata associated with the run request. + /// Optional configuration for run generation. + /// Identifier for the user making the request. + /// The agent configuration when not using a previously created agent. + /// Keeps track of any properties unknown to the library. + internal StreamRequest(string agentId, IReadOnlyList input, string conversationId, IReadOnlyDictionary metadata, RunOptions options, string userId, AgentConfigurationOptions agentConfiguration, IDictionary serializedAdditionalRawData) + { + AgentId = agentId; + Input = input; + ConversationId = conversationId; + Metadata = metadata; + Options = options; + UserId = userId; + AgentConfiguration = agentConfiguration; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal StreamRequest() + { + } + + /// Unique identifier for the agent responsible for the run. This is optional (not needeed) when doing a run using ephemeral agent. + public string AgentId { get; } + /// + /// The list of input messages for the run. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + public IReadOnlyList Input { get; } + /// Optional identifier for an existing conversation. + public string ConversationId { get; } + /// Optional metadata associated with the run request. + public IReadOnlyDictionary Metadata { get; } + /// Optional configuration for run generation. + public RunOptions Options { get; } + /// Identifier for the user making the request. + public string UserId { get; } + /// The agent configuration when not using a previously created agent. + public AgentConfigurationOptions AgentConfiguration { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/SystemMessage.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/SystemMessage.Serialization.cs new file mode 100644 index 000000000000..23f449a187b6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/SystemMessage.Serialization.cs @@ -0,0 +1,204 @@ +// 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.Projects.OneDP +{ + public partial class SystemMessage : 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 override 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(SystemMessage)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + SystemMessage 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(SystemMessage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSystemMessage(document.RootElement, options); + } + + internal static SystemMessage DeserializeSystemMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string userId = default; + string agentId = default; + string messageId = default; + string agentRunId = default; + string conversationId = default; + AuthorRole role = default; + IList content = default; + string authorName = default; + long? createdAt = default; + long? completedAt = 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("agentId"u8)) + { + agentId = property.Value.GetString(); + continue; + } + if (property.NameEquals("messageId"u8)) + { + messageId = property.Value.GetString(); + continue; + } + if (property.NameEquals("agentRunId"u8)) + { + agentRunId = property.Value.GetString(); + continue; + } + if (property.NameEquals("conversationId"u8)) + { + conversationId = property.Value.GetString(); + continue; + } + if (property.NameEquals("role"u8)) + { + role = new AuthorRole(property.Value.GetString()); + continue; + } + if (property.NameEquals("content"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AIContent.DeserializeAIContent(item, options)); + } + content = array; + continue; + } + if (property.NameEquals("authorName"u8)) + { + authorName = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdAt = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("completedAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + completedAt = property.Value.GetInt64(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SystemMessage( + userId, + agentId, + messageId, + agentRunId, + conversationId, + role, + content, + authorName, + createdAt, + completedAt, + 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(SystemMessage)} does not support writing '{options.Format}' format."); + } + } + + SystemMessage 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 DeserializeSystemMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SystemMessage)} 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 new SystemMessage FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSystemMessage(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/SystemMessage.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/SystemMessage.cs new file mode 100644 index 000000000000..3f1e68b244e8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/SystemMessage.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// A system message within a chat, always with the 'system' role. + public partial class SystemMessage : ChatMessage + { + /// Initializes a new instance of . + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// is null. + public SystemMessage(IEnumerable content) : base(content) + { + Argument.AssertNotNull(content, nameof(content)); + + Role = AuthorRole.System; + } + + /// Initializes a new instance of . + /// The ID of the user who created the message (if applicable). + /// The ID of the agent who created the message (if applicable). + /// A unique identifier for this message. + /// A unique run ID, if this message was generated by a run process. + /// The conversation to which this message belongs. + /// The role of this message's author. + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// An optional display name for the author. + /// The timestamp (in Unix time) when this message was created. + /// The timestamp (in Unix time) when this message was completed, if applicable. + /// Keeps track of any properties unknown to the library. + internal SystemMessage(string userId, string agentId, string messageId, string agentRunId, string conversationId, AuthorRole role, IList content, string authorName, long? createdAt, long? completedAt, IDictionary serializedAdditionalRawData) : base(userId, agentId, messageId, agentRunId, conversationId, role, content, authorName, createdAt, completedAt, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal SystemMessage() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/TextContent.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/TextContent.Serialization.cs new file mode 100644 index 000000000000..fa7c1228244e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/TextContent.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.Projects.OneDP +{ + public partial class TextContent : 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 override 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(TextContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + if (Optional.IsCollectionDefined(Annotations)) + { + writer.WritePropertyName("annotations"u8); + writer.WriteStartArray(); + foreach (var item in Annotations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + } + + TextContent 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(TextContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTextContent(document.RootElement, options); + } + + internal static TextContent DeserializeTextContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string text = default; + IList annotations = default; + string type = 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("annotations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(OneDP.Annotations.DeserializeAnnotations(item, options)); + } + annotations = array; + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TextContent(type, serializedAdditionalRawData, text, annotations ?? new ChangeTrackingList()); + } + + 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(TextContent)} does not support writing '{options.Format}' format."); + } + } + + TextContent 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 DeserializeTextContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TextContent)} 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 new TextContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTextContent(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/TextContent.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/TextContent.cs new file mode 100644 index 000000000000..c12d7dc02600 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/TextContent.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// A structured chat content item containing plain text. + public partial class TextContent : AIContent + { + /// Initializes a new instance of . + /// The text content. + /// is null. + public TextContent(string text) + { + Argument.AssertNotNull(text, nameof(text)); + + Type = "text"; + Text = text; + Annotations = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The text content. + /// A list of annotations in the text content. + internal TextContent(string type, IDictionary serializedAdditionalRawData, string text, IList annotations) : base(type, serializedAdditionalRawData) + { + Text = text; + Annotations = annotations; + } + + /// Initializes a new instance of for deserialization. + internal TextContent() + { + } + + /// The text content. + public string Text { get; set; } + /// A list of annotations in the text content. + public IList Annotations { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolCallContent.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolCallContent.Serialization.cs new file mode 100644 index 000000000000..14dd6d71ffa0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolCallContent.Serialization.cs @@ -0,0 +1,157 @@ +// 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.Projects.OneDP +{ + public partial class ToolCallContent : 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 override 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(ToolCallContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("toolCallId"u8); + writer.WriteStringValue(ToolCallId); + if (Optional.IsDefined(Arguments)) + { + writer.WritePropertyName("arguments"u8); + writer.WriteObjectValue(Arguments, options); + } + } + + ToolCallContent 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(ToolCallContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolCallContent(document.RootElement, options); + } + + internal static ToolCallContent DeserializeToolCallContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string toolCallId = default; + JSONAny arguments = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("toolCallId"u8)) + { + toolCallId = property.Value.GetString(); + continue; + } + if (property.NameEquals("arguments"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + arguments = JSONAny.DeserializeJSONAny(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ToolCallContent(type, serializedAdditionalRawData, name, toolCallId, arguments); + } + + 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(ToolCallContent)} does not support writing '{options.Format}' format."); + } + } + + ToolCallContent 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 DeserializeToolCallContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolCallContent)} 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 new ToolCallContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeToolCallContent(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolCallContent.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolCallContent.cs new file mode 100644 index 000000000000..79d45312bfa2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolCallContent.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// A structured chat content item describing a tool call request. + public partial class ToolCallContent : AIContent + { + /// Initializes a new instance of . + /// The name of the tool to call. + /// The unique ID of the tool call. + /// or is null. + public ToolCallContent(string name, string toolCallId) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(toolCallId, nameof(toolCallId)); + + Type = "toolCall"; + Name = name; + ToolCallId = toolCallId; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The name of the tool to call. + /// The unique ID of the tool call. + /// Arguments passed to this tool call, expressed as JSON-like data rather than `unknown`. + internal ToolCallContent(string type, IDictionary serializedAdditionalRawData, string name, string toolCallId, JSONAny arguments) : base(type, serializedAdditionalRawData) + { + Name = name; + ToolCallId = toolCallId; + Arguments = arguments; + } + + /// Initializes a new instance of for deserialization. + internal ToolCallContent() + { + } + + /// The name of the tool to call. + public string Name { get; set; } + /// The unique ID of the tool call. + public string ToolCallId { get; set; } + /// Arguments passed to this tool call, expressed as JSON-like data rather than `unknown`. + public JSONAny Arguments { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolChoiceBehavior.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolChoiceBehavior.Serialization.cs new file mode 100644 index 000000000000..3e79353a886e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolChoiceBehavior.Serialization.cs @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Projects.OneDP +{ + [PersistableModelProxy(typeof(UnknownToolChoiceBehavior))] + public partial class ToolChoiceBehavior : 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(ToolChoiceBehavior)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + 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 + } + } + } + + ToolChoiceBehavior 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(ToolChoiceBehavior)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolChoiceBehavior(document.RootElement, options); + } + + internal static ToolChoiceBehavior DeserializeToolChoiceBehavior(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "auto": return AutoToolChoiceBehavior.DeserializeAutoToolChoiceBehavior(element, options); + case "none": return NoneToolChoiceBehavior.DeserializeNoneToolChoiceBehavior(element, options); + case "required": return RequiredToolChoiceBehavior.DeserializeRequiredToolChoiceBehavior(element, options); + } + } + return UnknownToolChoiceBehavior.DeserializeUnknownToolChoiceBehavior(element, options); + } + + 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(ToolChoiceBehavior)} does not support writing '{options.Format}' format."); + } + } + + ToolChoiceBehavior 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 DeserializeToolChoiceBehavior(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolChoiceBehavior)} 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 ToolChoiceBehavior FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeToolChoiceBehavior(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/ai/Azure.AI.Projects.OneDP/src/Generated/ToolChoiceBehavior.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolChoiceBehavior.cs new file mode 100644 index 000000000000..ab8214060a5e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolChoiceBehavior.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.Projects.OneDP +{ + /// + /// The base behavior for how an agent chooses among available tools. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public abstract partial class ToolChoiceBehavior + { + /// + /// 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 protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected ToolChoiceBehavior() + { + } + + /// Initializes a new instance of . + /// The kind of tool-choice strategy. + /// Keeps track of any properties unknown to the library. + internal ToolChoiceBehavior(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The kind of tool-choice strategy. + internal string Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolMessage.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolMessage.Serialization.cs new file mode 100644 index 000000000000..8d7f91d3fde2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolMessage.Serialization.cs @@ -0,0 +1,213 @@ +// 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.Projects.OneDP +{ + public partial class ToolMessage : 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 override 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(ToolMessage)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("toolCallId"u8); + writer.WriteStringValue(ToolCallId); + } + + ToolMessage 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(ToolMessage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolMessage(document.RootElement, options); + } + + internal static ToolMessage DeserializeToolMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string toolCallId = default; + string userId = default; + string agentId = default; + string messageId = default; + string agentRunId = default; + string conversationId = default; + AuthorRole role = default; + IList content = default; + string authorName = default; + long? createdAt = default; + long? completedAt = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("toolCallId"u8)) + { + toolCallId = property.Value.GetString(); + continue; + } + if (property.NameEquals("userId"u8)) + { + userId = property.Value.GetString(); + continue; + } + if (property.NameEquals("agentId"u8)) + { + agentId = property.Value.GetString(); + continue; + } + if (property.NameEquals("messageId"u8)) + { + messageId = property.Value.GetString(); + continue; + } + if (property.NameEquals("agentRunId"u8)) + { + agentRunId = property.Value.GetString(); + continue; + } + if (property.NameEquals("conversationId"u8)) + { + conversationId = property.Value.GetString(); + continue; + } + if (property.NameEquals("role"u8)) + { + role = new AuthorRole(property.Value.GetString()); + continue; + } + if (property.NameEquals("content"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AIContent.DeserializeAIContent(item, options)); + } + content = array; + continue; + } + if (property.NameEquals("authorName"u8)) + { + authorName = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdAt = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("completedAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + completedAt = property.Value.GetInt64(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ToolMessage( + userId, + agentId, + messageId, + agentRunId, + conversationId, + role, + content, + authorName, + createdAt, + completedAt, + serializedAdditionalRawData, + toolCallId); + } + + 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(ToolMessage)} does not support writing '{options.Format}' format."); + } + } + + ToolMessage 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 DeserializeToolMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolMessage)} 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 new ToolMessage FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeToolMessage(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolMessage.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolMessage.cs new file mode 100644 index 000000000000..23f2902a60c1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolMessage.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// A tool message within a chat, always with the 'tool' role. + public partial class ToolMessage : ChatMessage + { + /// Initializes a new instance of . + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// The ID of the tool call to which this result pertains. + /// or is null. + public ToolMessage(IEnumerable content, string toolCallId) : base(content) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(toolCallId, nameof(toolCallId)); + + Role = AuthorRole.Tool; + ToolCallId = toolCallId; + } + + /// Initializes a new instance of . + /// The ID of the user who created the message (if applicable). + /// The ID of the agent who created the message (if applicable). + /// A unique identifier for this message. + /// A unique run ID, if this message was generated by a run process. + /// The conversation to which this message belongs. + /// The role of this message's author. + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// An optional display name for the author. + /// The timestamp (in Unix time) when this message was created. + /// The timestamp (in Unix time) when this message was completed, if applicable. + /// Keeps track of any properties unknown to the library. + /// The ID of the tool call to which this result pertains. + internal ToolMessage(string userId, string agentId, string messageId, string agentRunId, string conversationId, AuthorRole role, IList content, string authorName, long? createdAt, long? completedAt, IDictionary serializedAdditionalRawData, string toolCallId) : base(userId, agentId, messageId, agentRunId, conversationId, role, content, authorName, createdAt, completedAt, serializedAdditionalRawData) + { + ToolCallId = toolCallId; + } + + /// Initializes a new instance of for deserialization. + internal ToolMessage() + { + } + + /// The ID of the tool call to which this result pertains. + public string ToolCallId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolResultContent.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolResultContent.Serialization.cs new file mode 100644 index 000000000000..9186059ad541 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolResultContent.Serialization.cs @@ -0,0 +1,141 @@ +// 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.Projects.OneDP +{ + public partial class ToolResultContent : 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 override 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(ToolResultContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Results)) + { + writer.WritePropertyName("results"u8); + writer.WriteObjectValue(Results, options); + } + } + + ToolResultContent 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(ToolResultContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolResultContent(document.RootElement, options); + } + + internal static ToolResultContent DeserializeToolResultContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + JSONAny results = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("results"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + results = JSONAny.DeserializeJSONAny(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ToolResultContent(type, serializedAdditionalRawData, results); + } + + 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(ToolResultContent)} does not support writing '{options.Format}' format."); + } + } + + ToolResultContent 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 DeserializeToolResultContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolResultContent)} 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 new ToolResultContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeToolResultContent(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolResultContent.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolResultContent.cs new file mode 100644 index 000000000000..50c9eb22da4f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/ToolResultContent.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// A structured chat content item describing a tool result. + public partial class ToolResultContent : AIContent + { + /// Initializes a new instance of . + public ToolResultContent() + { + Type = "toolResult"; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The results returned from the tool, using JSONAny instead of `unknown`. + internal ToolResultContent(string type, IDictionary serializedAdditionalRawData, JSONAny results) : base(type, serializedAdditionalRawData) + { + Results = results; + } + + /// The results returned from the tool, using JSONAny instead of `unknown`. + public JSONAny Results { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/TruncationStrategy.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/TruncationStrategy.Serialization.cs new file mode 100644 index 000000000000..5e4d6bf99fab --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/TruncationStrategy.Serialization.cs @@ -0,0 +1,157 @@ +// 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.Projects.OneDP +{ + public partial class TruncationStrategy : 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(TruncationStrategy)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (Optional.IsDefined(LastMessages)) + { + writer.WritePropertyName("lastMessages"u8); + writer.WriteNumberValue(LastMessages.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 + } + } + } + + TruncationStrategy 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(TruncationStrategy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTruncationStrategy(document.RootElement, options); + } + + internal static TruncationStrategy DeserializeTruncationStrategy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TruncationStrategyType type = default; + int? lastMessages = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new TruncationStrategyType(property.Value.GetString()); + continue; + } + if (property.NameEquals("lastMessages"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastMessages = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TruncationStrategy(type, lastMessages, 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(TruncationStrategy)} does not support writing '{options.Format}' format."); + } + } + + TruncationStrategy 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 DeserializeTruncationStrategy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TruncationStrategy)} 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 TruncationStrategy FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTruncationStrategy(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/ai/Azure.AI.Projects.OneDP/src/Generated/TruncationStrategy.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/TruncationStrategy.cs new file mode 100644 index 000000000000..bcbd4d4f5cd7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/TruncationStrategy.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.Projects.OneDP +{ + /// Describes how to truncate messages if they exceed model or provider limits. + public partial class TruncationStrategy + { + /// + /// 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 type of truncation strategy to apply. Known values: 'auto', 'lastMessages', or a custom string. + public TruncationStrategy(TruncationStrategyType type) + { + Type = type; + } + + /// Initializes a new instance of . + /// The type of truncation strategy to apply. Known values: 'auto', 'lastMessages', or a custom string. + /// The number of most recent messages to retain when using 'lastMessages' strategy. + /// Keeps track of any properties unknown to the library. + internal TruncationStrategy(TruncationStrategyType type, int? lastMessages, IDictionary serializedAdditionalRawData) + { + Type = type; + LastMessages = lastMessages; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TruncationStrategy() + { + } + + /// The type of truncation strategy to apply. Known values: 'auto', 'lastMessages', or a custom string. + public TruncationStrategyType Type { get; set; } + /// The number of most recent messages to retain when using 'lastMessages' strategy. + public int? LastMessages { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/TruncationStrategyType.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/TruncationStrategyType.cs new file mode 100644 index 000000000000..343bfc5169fa --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/TruncationStrategyType.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.Projects.OneDP +{ + /// Enumerates known truncation strategy types, but also allows any custom fallback string. + public readonly partial struct TruncationStrategyType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TruncationStrategyType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AutoValue = "auto"; + private const string LastMessagesValue = "lastMessages"; + + /// Automatically truncate messages to fit limits. + public static TruncationStrategyType Auto { get; } = new TruncationStrategyType(AutoValue); + /// Truncate older messages, keeping only the last few. + public static TruncationStrategyType LastMessages { get; } = new TruncationStrategyType(LastMessagesValue); + /// Determines if two values are the same. + public static bool operator ==(TruncationStrategyType left, TruncationStrategyType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TruncationStrategyType left, TruncationStrategyType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator TruncationStrategyType(string value) => new TruncationStrategyType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TruncationStrategyType other && Equals(other); + /// + public bool Equals(TruncationStrategyType 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/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAIContent.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAIContent.Serialization.cs new file mode 100644 index 000000000000..69fcf7799cf5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAIContent.Serialization.cs @@ -0,0 +1,126 @@ +// 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.Projects.OneDP +{ + internal partial class UnknownAIContent : 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 override 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(AIContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + AIContent 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(AIContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAIContent(document.RootElement, options); + } + + internal static UnknownAIContent DeserializeUnknownAIContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownAIContent(type, 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(AIContent)} does not support writing '{options.Format}' format."); + } + } + + AIContent 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 DeserializeAIContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AIContent)} 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 new UnknownAIContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownAIContent(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAIContent.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAIContent.cs new file mode 100644 index 000000000000..15097aff68f2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAIContent.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Unknown version of AIContent. + internal partial class UnknownAIContent : AIContent + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownAIContent(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownAIContent() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAgentModel.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAgentModel.Serialization.cs new file mode 100644 index 000000000000..fa13b71e5bf0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAgentModel.Serialization.cs @@ -0,0 +1,148 @@ +// 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.Projects.OneDP +{ + internal partial class UnknownAgentModel : 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 override 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(AgentModel)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + AgentModel 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(AgentModel)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentModel(document.RootElement, options); + } + + internal static UnknownAgentModel DeserializeUnknownAgentModel(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string provider = "Unknown"; + string endpoint = default; + JSONAny options0 = 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("provider"u8)) + { + provider = property.Value.GetString(); + continue; + } + if (property.NameEquals("endpoint"u8)) + { + endpoint = property.Value.GetString(); + continue; + } + if (property.NameEquals("options"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + options0 = JSONAny.DeserializeJSONAny(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownAgentModel(id, provider, endpoint, options0, 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(AgentModel)} does not support writing '{options.Format}' format."); + } + } + + AgentModel 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 DeserializeAgentModel(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentModel)} 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 new UnknownAgentModel FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownAgentModel(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAgentModel.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAgentModel.cs new file mode 100644 index 000000000000..ccdd08383fb2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAgentModel.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Unknown version of AgentModel. + internal partial class UnknownAgentModel : AgentModel + { + /// Initializes a new instance of . + /// A unique model or deployment ID for this agent model. + /// The name of the provider for this model (e.g., 'openai'). + /// An endpoint where the provider can be reached, if applicable. + /// Provider-specific configuration and options (JSON-like structure). + /// Keeps track of any properties unknown to the library. + internal UnknownAgentModel(string id, string provider, string endpoint, JSONAny options, IDictionary serializedAdditionalRawData) : base(id, provider, endpoint, options, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownAgentModel() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAgentToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAgentToolDefinition.Serialization.cs new file mode 100644 index 000000000000..0daade28eaf4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAgentToolDefinition.Serialization.cs @@ -0,0 +1,146 @@ +// 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.Projects.OneDP +{ + internal partial class UnknownAgentToolDefinition : 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 override 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(AgentToolDefinition)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + AgentToolDefinition 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(AgentToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentToolDefinition(document.RootElement, options); + } + + internal static UnknownAgentToolDefinition DeserializeUnknownAgentToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + AgentToolOptions options0 = default; + AgentToolDefinitionOverride @override = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("options"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + options0 = AgentToolOptions.DeserializeAgentToolOptions(property.Value, options); + continue; + } + if (property.NameEquals("override"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + @override = AgentToolDefinitionOverride.DeserializeAgentToolDefinitionOverride(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownAgentToolDefinition(type, options0, @override, 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(AgentToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + AgentToolDefinition 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 DeserializeAgentToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentToolDefinition)} 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 new UnknownAgentToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownAgentToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAgentToolDefinition.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAgentToolDefinition.cs new file mode 100644 index 000000000000..fa404d9be861 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAgentToolDefinition.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Unknown version of AgentToolDefinition. + internal partial class UnknownAgentToolDefinition : AgentToolDefinition + { + /// Initializes a new instance of . + /// Discriminates the various child 'tool definition' types. + /// Additional options that specify the behavior of this tool (also polymorphic). + /// A set of overrides for the tool's name, description, or parameters. + /// Keeps track of any properties unknown to the library. + internal UnknownAgentToolDefinition(string type, AgentToolOptions options, AgentToolDefinitionOverride @override, IDictionary serializedAdditionalRawData) : base(type, options, @override, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownAgentToolDefinition() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAgentToolOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAgentToolOptions.Serialization.cs new file mode 100644 index 000000000000..9f410434c02e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAgentToolOptions.Serialization.cs @@ -0,0 +1,126 @@ +// 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.Projects.OneDP +{ + internal partial class UnknownAgentToolOptions : 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 override 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(AgentToolOptions)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + AgentToolOptions 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(AgentToolOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentToolOptions(document.RootElement, options); + } + + internal static UnknownAgentToolOptions DeserializeUnknownAgentToolOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownAgentToolOptions(type, 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(AgentToolOptions)} does not support writing '{options.Format}' format."); + } + } + + AgentToolOptions 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 DeserializeAgentToolOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentToolOptions)} 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 new UnknownAgentToolOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownAgentToolOptions(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAgentToolOptions.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAgentToolOptions.cs new file mode 100644 index 000000000000..960515a5086e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownAgentToolOptions.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Unknown version of AgentToolOptions. + internal partial class UnknownAgentToolOptions : AgentToolOptions + { + /// Initializes a new instance of . + /// Discriminates the various child 'tool options' types. + /// Keeps track of any properties unknown to the library. + internal UnknownAgentToolOptions(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownAgentToolOptions() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownBaseCredential.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownBaseCredential.Serialization.cs new file mode 100644 index 000000000000..f4d713364295 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownBaseCredential.Serialization.cs @@ -0,0 +1,126 @@ +// 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.Projects.OneDP +{ + internal partial class UnknownBaseCredential : 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 override 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(BaseCredential)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + BaseCredential 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(BaseCredential)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBaseCredential(document.RootElement, options); + } + + internal static UnknownBaseCredential DeserializeUnknownBaseCredential(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CredentialType type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new CredentialType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownBaseCredential(type, 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(BaseCredential)} does not support writing '{options.Format}' format."); + } + } + + BaseCredential 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 DeserializeBaseCredential(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BaseCredential)} 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 new UnknownBaseCredential FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownBaseCredential(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownBaseCredential.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownBaseCredential.cs new file mode 100644 index 000000000000..10e5401bbe48 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownBaseCredential.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Unknown version of BaseCredential. + internal partial class UnknownBaseCredential : BaseCredential + { + /// Initializes a new instance of . + /// Type of credential. Possible values are: AAD, SAS, ApiKey. + /// Keeps track of any properties unknown to the library. + internal UnknownBaseCredential(CredentialType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownBaseCredential() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownChatMessage.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownChatMessage.Serialization.cs new file mode 100644 index 000000000000..9f62e9d612b9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownChatMessage.Serialization.cs @@ -0,0 +1,204 @@ +// 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.Projects.OneDP +{ + internal partial class UnknownChatMessage : 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 override 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(ChatMessage)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + ChatMessage 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(ChatMessage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatMessage(document.RootElement, options); + } + + internal static UnknownChatMessage DeserializeUnknownChatMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string userId = default; + string agentId = default; + string messageId = default; + string agentRunId = default; + string conversationId = default; + AuthorRole role = "Unknown"; + IList content = default; + string authorName = default; + long? createdAt = default; + long? completedAt = 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("agentId"u8)) + { + agentId = property.Value.GetString(); + continue; + } + if (property.NameEquals("messageId"u8)) + { + messageId = property.Value.GetString(); + continue; + } + if (property.NameEquals("agentRunId"u8)) + { + agentRunId = property.Value.GetString(); + continue; + } + if (property.NameEquals("conversationId"u8)) + { + conversationId = property.Value.GetString(); + continue; + } + if (property.NameEquals("role"u8)) + { + role = new AuthorRole(property.Value.GetString()); + continue; + } + if (property.NameEquals("content"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AIContent.DeserializeAIContent(item, options)); + } + content = array; + continue; + } + if (property.NameEquals("authorName"u8)) + { + authorName = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdAt = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("completedAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + completedAt = property.Value.GetInt64(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownChatMessage( + userId, + agentId, + messageId, + agentRunId, + conversationId, + role, + content, + authorName, + createdAt, + completedAt, + 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(ChatMessage)} does not support writing '{options.Format}' format."); + } + } + + ChatMessage 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 DeserializeChatMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatMessage)} 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 new UnknownChatMessage FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownChatMessage(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownChatMessage.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownChatMessage.cs new file mode 100644 index 000000000000..32c9a32304b0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownChatMessage.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Unknown version of ChatMessage. + internal partial class UnknownChatMessage : ChatMessage + { + /// Initializes a new instance of . + /// The ID of the user who created the message (if applicable). + /// The ID of the agent who created the message (if applicable). + /// A unique identifier for this message. + /// A unique run ID, if this message was generated by a run process. + /// The conversation to which this message belongs. + /// The role of this message's author. + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// An optional display name for the author. + /// The timestamp (in Unix time) when this message was created. + /// The timestamp (in Unix time) when this message was completed, if applicable. + /// Keeps track of any properties unknown to the library. + internal UnknownChatMessage(string userId, string agentId, string messageId, string agentRunId, string conversationId, AuthorRole role, IList content, string authorName, long? createdAt, long? completedAt, IDictionary serializedAdditionalRawData) : base(userId, agentId, messageId, agentRunId, conversationId, role, content, authorName, createdAt, completedAt, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownChatMessage() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownDatasetVersion.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownDatasetVersion.Serialization.cs new file mode 100644 index 000000000000..c2fae38b9fdc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownDatasetVersion.Serialization.cs @@ -0,0 +1,197 @@ +// 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.Projects.OneDP +{ + internal partial class UnknownDatasetVersion : 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 override 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(DatasetVersion)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + DatasetVersion 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(DatasetVersion)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDatasetVersion(document.RootElement, options); + } + + internal static UnknownDatasetVersion DeserializeUnknownDatasetVersion(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string datasetUri = default; + DatasetType type = "Unknown"; + bool? isReference = default; + string stage = default; + string id = default; + string name = default; + string version = default; + string description = default; + IDictionary tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("datasetUri"u8)) + { + datasetUri = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new DatasetType(property.Value.GetString()); + continue; + } + if (property.NameEquals("isReference"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isReference = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("stage"u8)) + { + stage = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("version"u8)) + { + version = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"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()); + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownDatasetVersion( + datasetUri, + type, + isReference, + stage, + id, + name, + version, + description, + tags ?? new ChangeTrackingDictionary(), + 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(DatasetVersion)} does not support writing '{options.Format}' format."); + } + } + + DatasetVersion 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 DeserializeDatasetVersion(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DatasetVersion)} 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 new UnknownDatasetVersion FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownDatasetVersion(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownDatasetVersion.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownDatasetVersion.cs new file mode 100644 index 000000000000..d2703979e4a8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownDatasetVersion.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Unknown version of DatasetVersion. + internal partial class UnknownDatasetVersion : DatasetVersion + { + /// Initializes a new instance of . + /// [Required] Uri of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// Dataset type. + /// Indicates if dataset is reference only or managed by dataset service. If true, the underlying data will be deleted when the dataset version is deleted. + /// Asset stage. + /// A unique identifier for the asset, assetId probably?. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Keeps track of any properties unknown to the library. + internal UnknownDatasetVersion(string datasetUri, DatasetType type, bool? isReference, string stage, string id, string name, string version, string description, IDictionary tags, IDictionary serializedAdditionalRawData) : base(datasetUri, type, isReference, stage, id, name, version, description, tags, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownDatasetVersion() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownDeployment.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownDeployment.Serialization.cs new file mode 100644 index 000000000000..894a3d9deaa8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownDeployment.Serialization.cs @@ -0,0 +1,132 @@ +// 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.Projects.OneDP +{ + internal partial class UnknownDeployment : 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 override 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(Deployment)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + Deployment 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(Deployment)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDeployment(document.RootElement, options); + } + + internal static UnknownDeployment DeserializeUnknownDeployment(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DeploymentType type = "Unknown"; + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new DeploymentType(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownDeployment(type, name, 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(Deployment)} does not support writing '{options.Format}' format."); + } + } + + Deployment 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 DeserializeDeployment(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Deployment)} 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 new UnknownDeployment FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownDeployment(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownDeployment.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownDeployment.cs new file mode 100644 index 000000000000..4769b1e46cda --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownDeployment.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Unknown version of Deployment. + internal partial class UnknownDeployment : Deployment + { + /// Initializes a new instance of . + /// The type of the deployment. + /// Name of the deployment. + /// Keeps track of any properties unknown to the library. + internal UnknownDeployment(DeploymentType type, string name, IDictionary serializedAdditionalRawData) : base(type, name, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownDeployment() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownIndex.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownIndex.Serialization.cs new file mode 100644 index 000000000000..1181af9e71bf --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownIndex.Serialization.cs @@ -0,0 +1,179 @@ +// 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.Projects.OneDP +{ + internal partial class UnknownIndex : 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 override 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(Index)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + Index 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(Index)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIndex(document.RootElement, options); + } + + internal static UnknownIndex DeserializeUnknownIndex(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IndexType type = "Unknown"; + string stage = default; + string id = default; + string name = default; + string version = default; + string description = default; + IDictionary tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new IndexType(property.Value.GetString()); + continue; + } + if (property.NameEquals("stage"u8)) + { + stage = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("version"u8)) + { + version = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"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()); + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownIndex( + type, + stage, + id, + name, + version, + description, + tags ?? new ChangeTrackingDictionary(), + 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(Index)} does not support writing '{options.Format}' format."); + } + } + + Index 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 DeserializeIndex(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Index)} 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 new UnknownIndex FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownIndex(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownIndex.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownIndex.cs new file mode 100644 index 000000000000..e3f9813a90eb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownIndex.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Unknown version of Index. + internal partial class UnknownIndex : Index + { + /// Initializes a new instance of . + /// Type of index. + /// Asset stage. + /// A unique identifier for the asset, assetId probably?. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Keeps track of any properties unknown to the library. + internal UnknownIndex(IndexType type, string stage, string id, string name, string version, string description, IDictionary tags, IDictionary serializedAdditionalRawData) : base(type, stage, id, name, version, description, tags, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownIndex() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownInputData.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownInputData.Serialization.cs new file mode 100644 index 000000000000..2881272fd130 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownInputData.Serialization.cs @@ -0,0 +1,126 @@ +// 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.Projects.OneDP +{ + internal partial class UnknownInputData : 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 override 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(InputData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + InputData 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(InputData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInputData(document.RootElement, options); + } + + internal static UnknownInputData DeserializeUnknownInputData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownInputData(type, 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(InputData)} does not support writing '{options.Format}' format."); + } + } + + InputData 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 DeserializeInputData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InputData)} 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 new UnknownInputData FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownInputData(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownInputData.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownInputData.cs new file mode 100644 index 000000000000..02428d223358 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownInputData.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Unknown version of InputData. + internal partial class UnknownInputData : InputData + { + /// Initializes a new instance of . + /// Type of the data. + /// Keeps track of any properties unknown to the library. + internal UnknownInputData(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownInputData() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownToolChoiceBehavior.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownToolChoiceBehavior.Serialization.cs new file mode 100644 index 000000000000..f88a639bba00 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownToolChoiceBehavior.Serialization.cs @@ -0,0 +1,126 @@ +// 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.Projects.OneDP +{ + internal partial class UnknownToolChoiceBehavior : 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 override 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(ToolChoiceBehavior)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + ToolChoiceBehavior 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(ToolChoiceBehavior)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolChoiceBehavior(document.RootElement, options); + } + + internal static UnknownToolChoiceBehavior DeserializeUnknownToolChoiceBehavior(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownToolChoiceBehavior(type, 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(ToolChoiceBehavior)} does not support writing '{options.Format}' format."); + } + } + + ToolChoiceBehavior 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 DeserializeToolChoiceBehavior(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolChoiceBehavior)} 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 new UnknownToolChoiceBehavior FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownToolChoiceBehavior(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownToolChoiceBehavior.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownToolChoiceBehavior.cs new file mode 100644 index 000000000000..2dec141369d7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UnknownToolChoiceBehavior.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// Unknown version of ToolChoiceBehavior. + internal partial class UnknownToolChoiceBehavior : ToolChoiceBehavior + { + /// Initializes a new instance of . + /// The kind of tool-choice strategy. + /// Keeps track of any properties unknown to the library. + internal UnknownToolChoiceBehavior(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownToolChoiceBehavior() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UserMessage.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UserMessage.Serialization.cs new file mode 100644 index 000000000000..65c1da3dfb10 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UserMessage.Serialization.cs @@ -0,0 +1,204 @@ +// 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.Projects.OneDP +{ + public partial class UserMessage : 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 override 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(UserMessage)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + UserMessage 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(UserMessage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUserMessage(document.RootElement, options); + } + + internal static UserMessage DeserializeUserMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string userId = default; + string agentId = default; + string messageId = default; + string agentRunId = default; + string conversationId = default; + AuthorRole role = default; + IList content = default; + string authorName = default; + long? createdAt = default; + long? completedAt = 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("agentId"u8)) + { + agentId = property.Value.GetString(); + continue; + } + if (property.NameEquals("messageId"u8)) + { + messageId = property.Value.GetString(); + continue; + } + if (property.NameEquals("agentRunId"u8)) + { + agentRunId = property.Value.GetString(); + continue; + } + if (property.NameEquals("conversationId"u8)) + { + conversationId = property.Value.GetString(); + continue; + } + if (property.NameEquals("role"u8)) + { + role = new AuthorRole(property.Value.GetString()); + continue; + } + if (property.NameEquals("content"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AIContent.DeserializeAIContent(item, options)); + } + content = array; + continue; + } + if (property.NameEquals("authorName"u8)) + { + authorName = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdAt = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("completedAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + completedAt = property.Value.GetInt64(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UserMessage( + userId, + agentId, + messageId, + agentRunId, + conversationId, + role, + content, + authorName, + createdAt, + completedAt, + 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(UserMessage)} does not support writing '{options.Format}' format."); + } + } + + UserMessage 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 DeserializeUserMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UserMessage)} 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 new UserMessage FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUserMessage(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UserMessage.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UserMessage.cs new file mode 100644 index 000000000000..3398bec444f1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/UserMessage.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OneDP +{ + /// A user message within a chat, always with the 'user' role. + public partial class UserMessage : ChatMessage + { + /// Initializes a new instance of . + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// is null. + public UserMessage(IEnumerable content) : base(content) + { + Argument.AssertNotNull(content, nameof(content)); + + Role = AuthorRole.User; + } + + /// Initializes a new instance of . + /// The ID of the user who created the message (if applicable). + /// The ID of the agent who created the message (if applicable). + /// A unique identifier for this message. + /// A unique run ID, if this message was generated by a run process. + /// The conversation to which this message belongs. + /// The role of this message's author. + /// + /// The contents of the message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// An optional display name for the author. + /// The timestamp (in Unix time) when this message was created. + /// The timestamp (in Unix time) when this message was completed, if applicable. + /// Keeps track of any properties unknown to the library. + internal UserMessage(string userId, string agentId, string messageId, string agentRunId, string conversationId, AuthorRole role, IList content, string authorName, long? createdAt, long? completedAt, IDictionary serializedAdditionalRawData) : base(userId, agentId, messageId, agentRunId, conversationId, role, content, authorName, createdAt, completedAt, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UserMessage() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/VideoContent.Serialization.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/VideoContent.Serialization.cs new file mode 100644 index 000000000000..a55c1215fc77 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/VideoContent.Serialization.cs @@ -0,0 +1,248 @@ +// 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.Projects.OneDP +{ + public partial class VideoContent : 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 override 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(VideoContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Duration)) + { + writer.WritePropertyName("duration"u8); + writer.WriteObjectValue(Duration, options); + } + if (Optional.IsDefined(Width)) + { + writer.WritePropertyName("width"u8); + writer.WriteObjectValue(Width, options); + } + if (Optional.IsDefined(Height)) + { + writer.WritePropertyName("height"u8); + writer.WriteObjectValue(Height, options); + } + if (Optional.IsDefined(FileName)) + { + writer.WritePropertyName("fileName"u8); + writer.WriteStringValue(FileName); + } + if (Optional.IsDefined(MimeType)) + { + writer.WritePropertyName("mimeType"u8); + writer.WriteStringValue(MimeType); + } + if (Optional.IsDefined(Uri)) + { + writer.WritePropertyName("uri"u8); + writer.WriteStringValue(Uri.AbsoluteUri); + } + if (Optional.IsDefined(DataUri)) + { + writer.WritePropertyName("dataUri"u8); + writer.WriteStringValue(DataUri.AbsoluteUri); + } + if (Optional.IsDefined(Data)) + { + writer.WritePropertyName("data"u8); + writer.WriteBase64StringValue(Data.ToArray(), "D"); + } + } + + VideoContent 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(VideoContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVideoContent(document.RootElement, options); + } + + internal static VideoContent DeserializeVideoContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + object duration = default; + object width = default; + object height = default; + string fileName = default; + string mimeType = default; + Uri uri = default; + Uri dataUri = default; + BinaryData data = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("duration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + duration = property.Value.GetObject(); + continue; + } + if (property.NameEquals("width"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + width = property.Value.GetObject(); + continue; + } + if (property.NameEquals("height"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + height = property.Value.GetObject(); + continue; + } + if (property.NameEquals("fileName"u8)) + { + fileName = property.Value.GetString(); + continue; + } + if (property.NameEquals("mimeType"u8)) + { + mimeType = property.Value.GetString(); + continue; + } + if (property.NameEquals("uri"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + uri = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("dataUri"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataUri = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("data"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + data = BinaryData.FromBytes(property.Value.GetBytesFromBase64("D")); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VideoContent( + type, + serializedAdditionalRawData, + duration, + width, + height, + fileName, + mimeType, + uri, + dataUri, + data); + } + + 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(VideoContent)} does not support writing '{options.Format}' format."); + } + } + + VideoContent 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 DeserializeVideoContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VideoContent)} 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 new VideoContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVideoContent(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/VideoContent.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/VideoContent.cs new file mode 100644 index 000000000000..f3c935903c83 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/src/Generated/VideoContent.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.Projects.OneDP +{ + /// A structured chat content item containing a video reference. + public partial class VideoContent : AIContent + { + /// Initializes a new instance of . + public VideoContent() + { + Type = "video"; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// Duration of video in seconds (optional). + /// Width of video in pixels (optional). + /// Height of video in pixels (optional). + /// The file name for this binary content. + /// The MIME type for this binary content. + /// URI where the binary content can be retrieved. + /// Data URI containing the binary content inlined. + /// Raw bytes for the binary content. + internal VideoContent(string type, IDictionary serializedAdditionalRawData, object duration, object width, object height, string fileName, string mimeType, Uri uri, Uri dataUri, BinaryData data) : base(type, serializedAdditionalRawData) + { + Duration = duration; + Width = width; + Height = height; + FileName = fileName; + MimeType = mimeType; + Uri = uri; + DataUri = dataUri; + Data = data; + } + + /// Duration of video in seconds (optional). + public object Duration { get; set; } + /// Width of video in pixels (optional). + public object Width { get; set; } + /// Height of video in pixels (optional). + public object Height { get; set; } + /// The file name for this binary content. + public string FileName { get; set; } + /// The MIME type for this binary content. + public string MimeType { get; set; } + /// URI where the binary content can be retrieved. + public Uri Uri { get; set; } + /// Data URI containing the binary content inlined. + public Uri DataUri { get; set; } + /// + /// Raw bytes for the binary content. + /// + /// To assign a byte[] to this property use . + /// The byte[] will be serialized to a Base64 encoded string. + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromBytes(new byte[] { 1, 2, 3 }) + /// Creates a payload of "AQID". + /// + /// + /// + /// + public BinaryData Data { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/src/Properties/AssemblyInfo.cs b/sdk/ai/Azure.AI.Projects.OneDP/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..e4cec55a9640 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/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.Projects.OneDP.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/ai/Azure.AI.Projects.OneDP/tests/Azure.AI.Projects.OneDP.Tests.csproj b/sdk/ai/Azure.AI.Projects.OneDP/tests/Azure.AI.Projects.OneDP.Tests.csproj new file mode 100644 index 000000000000..7ba2cc3c01f3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/tests/Azure.AI.Projects.OneDP.Tests.csproj @@ -0,0 +1,20 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + + + + + + + + + + + + + + diff --git a/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Agents.cs b/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Agents.cs new file mode 100644 index 000000000000..312a4aa1c569 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Agents.cs @@ -0,0 +1,2720 @@ +// 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 System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AI.Projects.OneDP.Samples +{ + public partial class Samples_Agents + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_CreateAgent_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + displayName = "", + }); + Response response = client.CreateAgent(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_CreateAgent_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + displayName = "", + }); + Response response = await client.CreateAgentAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_CreateAgent_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.CreateAgent(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_CreateAgent_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.CreateAgentAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_CreateAgent_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + displayName = "", + agentModel = new + { + provider = "openai", + options = new + { + temperature = 123.45F, + topP = 123.45F, + }, + id = "", + endpoint = "", + }, + instructions = "", + tools = new object[] + { +new Dictionary +{ +["type"] = "Function", +["name"] = "", +["description"] = "", +["parameters"] = new +{ +type = "", +properties = new {}, +required = new object[] +{ +"" +}, +}, +["strict"] = true, +["options"] = null, +["override"] = new +{ +name = "", +description = "", +} +} + }, + toolChoice = new + { + type = "auto", + toolNames = new object[] + { +"" + }, + }, + }); + Response response = client.CreateAgent(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("provider").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("endpoint").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("instructions").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("toolChoice").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_CreateAgent_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + displayName = "", + agentModel = new + { + provider = "openai", + options = new + { + temperature = 123.45F, + topP = 123.45F, + }, + id = "", + endpoint = "", + }, + instructions = "", + tools = new object[] + { +new Dictionary +{ +["type"] = "Function", +["name"] = "", +["description"] = "", +["parameters"] = new +{ +type = "", +properties = new {}, +required = new object[] +{ +"" +}, +}, +["strict"] = true, +["options"] = null, +["override"] = new +{ +name = "", +description = "", +} +} + }, + toolChoice = new + { + type = "auto", + toolNames = new object[] + { +"" + }, + }, + }); + Response response = await client.CreateAgentAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("provider").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("endpoint").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("instructions").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("toolChoice").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_CreateAgent_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + AgentModel agentModel = new OpenAIAgentModel("", new JSONAny()) + { + Endpoint = "", + }; + ToolChoiceBehavior toolChoice = new AutoToolChoiceBehavior(new string[] { "" }); + Response response = client.CreateAgent("", agentModel: agentModel, instructions: "", tools: new AgentToolDefinition[] + { +new FunctionToolDefinition("") +{ +Description = "", +Parameters = new JSONSchema("", new Dictionary +{ +["key"] = default +}) +{ +Required = {""}, +}, +Strict = true, +Options = default, +Override = new AgentToolDefinitionOverride +{ +Name = "", +Description = "", +Parameters = default, +}, +} + }, toolChoice: toolChoice); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_CreateAgent_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + AgentModel agentModel = new OpenAIAgentModel("", new JSONAny()) + { + Endpoint = "", + }; + ToolChoiceBehavior toolChoice = new AutoToolChoiceBehavior(new string[] { "" }); + Response response = await client.CreateAgentAsync("", agentModel: agentModel, instructions: "", tools: new AgentToolDefinition[] + { +new FunctionToolDefinition("") +{ +Description = "", +Parameters = new JSONSchema("", new Dictionary +{ +["key"] = default +}) +{ +Required = {""}, +}, +Strict = true, +Options = default, +Override = new AgentToolDefinitionOverride +{ +Name = "", +Description = "", +Parameters = default, +}, +} + }, toolChoice: toolChoice); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_GetAgent_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetAgent("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_GetAgent_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetAgentAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_GetAgent_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetAgent(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_GetAgent_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetAgentAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_GetAgent_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetAgent("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("provider").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("endpoint").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("instructions").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("toolChoice").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_GetAgent_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetAgentAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("provider").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("endpoint").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("instructions").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("toolChoice").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_GetAgent_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetAgent(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_GetAgent_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetAgentAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_UpdateAgent_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + configurationOptions = new + { + displayName = "", + }, + }); + Response response = client.UpdateAgent("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_UpdateAgent_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + configurationOptions = new + { + displayName = "", + }, + }); + Response response = await client.UpdateAgentAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_UpdateAgent_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Agent body = new Agent(new AgentConfigurationOptions("")); + Response response = client.UpdateAgent("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_UpdateAgent_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Agent body = new Agent(new AgentConfigurationOptions("")); + Response response = await client.UpdateAgentAsync("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_UpdateAgent_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + description = "", + metadata = new + { + key = "", + }, + configurationOptions = new + { + displayName = "", + agentModel = new + { + provider = "openai", + options = new + { + temperature = 123.45F, + topP = 123.45F, + }, + id = "", + endpoint = "", + }, + instructions = "", + tools = new object[] + { +new Dictionary +{ +["type"] = "Function", +["name"] = "", +["description"] = "", +["parameters"] = new +{ +type = "", +properties = new {}, +required = new object[] +{ +"" +}, +}, +["strict"] = true, +["options"] = null, +["override"] = new +{ +name = "", +description = "", +} +} + }, + toolChoice = new + { + type = "auto", + toolNames = new object[] + { +"" + }, + }, + }, + }); + Response response = client.UpdateAgent("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("provider").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("endpoint").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("instructions").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("toolChoice").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_UpdateAgent_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + description = "", + metadata = new + { + key = "", + }, + configurationOptions = new + { + displayName = "", + agentModel = new + { + provider = "openai", + options = new + { + temperature = 123.45F, + topP = 123.45F, + }, + id = "", + endpoint = "", + }, + instructions = "", + tools = new object[] + { +new Dictionary +{ +["type"] = "Function", +["name"] = "", +["description"] = "", +["parameters"] = new +{ +type = "", +properties = new {}, +required = new object[] +{ +"" +}, +}, +["strict"] = true, +["options"] = null, +["override"] = new +{ +name = "", +description = "", +} +} + }, + toolChoice = new + { + type = "auto", + toolNames = new object[] + { +"" + }, + }, + }, + }); + Response response = await client.UpdateAgentAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("provider").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("endpoint").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("instructions").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); + Console.WriteLine(result.GetProperty("configurationOptions").GetProperty("toolChoice").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_UpdateAgent_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Agent body = new Agent(new AgentConfigurationOptions("") + { + AgentModel = new OpenAIAgentModel("", new JSONAny()) + { + Endpoint = "", + }, + Instructions = "", + Tools = {new FunctionToolDefinition("") +{ +Description = "", +Parameters = new JSONSchema("", new Dictionary +{ +["key"] = default +}) +{ +Required = {""}, +}, +Strict = true, +Options = default, +Override = new AgentToolDefinitionOverride +{ +Name = "", +Description = "", +Parameters = default, +}, +}}, + ToolChoice = new AutoToolChoiceBehavior(new string[] { "" }), + }) + { + Description = "", + Metadata = +{ +["key"] = "" +}, + }; + Response response = client.UpdateAgent("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_UpdateAgent_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Agent body = new Agent(new AgentConfigurationOptions("") + { + AgentModel = new OpenAIAgentModel("", new JSONAny()) + { + Endpoint = "", + }, + Instructions = "", + Tools = {new FunctionToolDefinition("") +{ +Description = "", +Parameters = new JSONSchema("", new Dictionary +{ +["key"] = default +}) +{ +Required = {""}, +}, +Strict = true, +Options = default, +Override = new AgentToolDefinitionOverride +{ +Name = "", +Description = "", +Parameters = default, +}, +}}, + ToolChoice = new AutoToolChoiceBehavior(new string[] { "" }), + }) + { + Description = "", + Metadata = +{ +["key"] = "" +}, + }; + Response response = await client.UpdateAgentAsync("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_DeleteAgent_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.DeleteAgent(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_DeleteAgent_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.DeleteAgentAsync(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_DeleteAgent_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.DeleteAgent(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_DeleteAgent_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.DeleteAgentAsync(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_GetAgents_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetAgents(null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result[0].GetProperty("agentId").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("displayName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_GetAgents_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetAgentsAsync(null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result[0].GetProperty("agentId").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("displayName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_GetAgents_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response> response = client.GetAgents(); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_GetAgents_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response> response = await client.GetAgentsAsync(); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_GetAgents_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetAgents(null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result[0].GetProperty("agentId").ToString()); + Console.WriteLine(result[0].GetProperty("description").ToString()); + Console.WriteLine(result[0].GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("displayName").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("id").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("provider").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("endpoint").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("instructions").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("type").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("toolChoice").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_GetAgents_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetAgentsAsync(null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result[0].GetProperty("agentId").ToString()); + Console.WriteLine(result[0].GetProperty("description").ToString()); + Console.WriteLine(result[0].GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("displayName").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("id").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("provider").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("endpoint").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("instructions").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("type").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); + Console.WriteLine(result[0].GetProperty("configurationOptions").GetProperty("toolChoice").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_GetAgents_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response> response = client.GetAgents(); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_GetAgents_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response> response = await client.GetAgentsAsync(); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_Run_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + input = new object[] + { +new +{ +role = "user", +content = new object[] +{ +new +{ +type = "text", +text = "", +} +}, +} + }, + }); + Response response = client.Run(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("runId").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_Run_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + input = new object[] + { +new +{ +role = "user", +content = new object[] +{ +new +{ +type = "text", +text = "", +} +}, +} + }, + }); + Response response = await client.RunAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("runId").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_Run_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.Run(new ChatMessage[] + { +new UserMessage(new AIContent[] +{ +new TextContent("") +}) + }); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_Run_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.RunAsync(new ChatMessage[] + { +new UserMessage(new AIContent[] +{ +new TextContent("") +}) + }); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_Run_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + agentId = "", + input = new object[] + { +new +{ +role = "user", +content = new object[] +{ +new +{ +type = "text", +text = "", +annotations = new object[] +{ +new +{ +type = "", +ToolCallId = "", +jsonPath = "", +url = "", +start = 1234, +end = 1234, +} +}, +} +}, +userId = "", +agentId = "", +agentRunId = "", +authorName = "", +createdAt = 1234L, +completedAt = 1234L, +} + }, + conversationId = "", + metadata = new + { + key = "", + }, + options = new + { + truncationStrategy = new + { + type = "auto", + lastMessages = 1234, + }, + }, + userId = "", + agentConfiguration = new + { + displayName = "", + agentModel = new + { + provider = "openai", + options = new + { + temperature = 123.45F, + topP = 123.45F, + }, + id = "", + endpoint = "", + }, + instructions = "", + tools = new object[] + { +new Dictionary +{ +["type"] = "Function", +["name"] = "", +["description"] = "", +["parameters"] = new +{ +type = "", +properties = new {}, +required = new object[] +{ +"" +}, +}, +["strict"] = true, +["options"] = null, +["override"] = new +{ +name = "", +description = "", +} +} + }, + toolChoice = new + { + type = "auto", + toolNames = new object[] + { +"" + }, + }, + }, + }); + Response response = client.Run(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("runId").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("lastMessages").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("provider").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("endpoint").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("instructions").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("toolChoice").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("store").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokenDetails").GetProperty("cachedTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokenDetails").GetProperty("reasoningTokens").ToString()); + Console.WriteLine(result.GetProperty("incompleteDetails").GetProperty("reason").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_Run_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + agentId = "", + input = new object[] + { +new +{ +role = "user", +content = new object[] +{ +new +{ +type = "text", +text = "", +annotations = new object[] +{ +new +{ +type = "", +ToolCallId = "", +jsonPath = "", +url = "", +start = 1234, +end = 1234, +} +}, +} +}, +userId = "", +agentId = "", +agentRunId = "", +authorName = "", +createdAt = 1234L, +completedAt = 1234L, +} + }, + conversationId = "", + metadata = new + { + key = "", + }, + options = new + { + truncationStrategy = new + { + type = "auto", + lastMessages = 1234, + }, + }, + userId = "", + agentConfiguration = new + { + displayName = "", + agentModel = new + { + provider = "openai", + options = new + { + temperature = 123.45F, + topP = 123.45F, + }, + id = "", + endpoint = "", + }, + instructions = "", + tools = new object[] + { +new Dictionary +{ +["type"] = "Function", +["name"] = "", +["description"] = "", +["parameters"] = new +{ +type = "", +properties = new {}, +required = new object[] +{ +"" +}, +}, +["strict"] = true, +["options"] = null, +["override"] = new +{ +name = "", +description = "", +} +} + }, + toolChoice = new + { + type = "auto", + toolNames = new object[] + { +"" + }, + }, + }, + }); + Response response = await client.RunAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("runId").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("lastMessages").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("provider").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("endpoint").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("instructions").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("toolChoice").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("store").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokenDetails").GetProperty("cachedTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokenDetails").GetProperty("reasoningTokens").ToString()); + Console.WriteLine(result.GetProperty("incompleteDetails").GetProperty("reason").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_Run_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + RunOptions options = new RunOptions + { + TruncationStrategy = new TruncationStrategy(TruncationStrategyType.Auto) + { + LastMessages = 1234, + }, + }; + AgentConfigurationOptions agentConfiguration = new AgentConfigurationOptions("") + { + AgentModel = new OpenAIAgentModel("", new JSONAny()) + { + Endpoint = "", + }, + Instructions = "", + Tools = {new FunctionToolDefinition("") +{ +Description = "", +Parameters = new JSONSchema("", new Dictionary +{ +["key"] = default +}) +{ +Required = {""}, +}, +Strict = true, +Options = default, +Override = new AgentToolDefinitionOverride +{ +Name = "", +Description = "", +Parameters = default, +}, +}}, + ToolChoice = new AutoToolChoiceBehavior(new string[] { "" }), + }; + Response response = client.Run(new ChatMessage[] + { +new UserMessage(new AIContent[] +{ +new TextContent("") +{ +Annotations = {new Annotations("") +{ +ToolCallId = "", +JsonPath = "", +Url = "", +Start = 1234, +End = 1234, +}}, +} +}) +{ +UserId = "", +AgentId = "", +AgentRunId = "", +AuthorName = "", +CreatedAt = 1234L, +CompletedAt = 1234L, +} + }, agentId: "", conversationId: "", metadata: new Dictionary + { + ["key"] = "" + }, options: options, userId: "", agentConfiguration: agentConfiguration); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_Run_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + RunOptions options = new RunOptions + { + TruncationStrategy = new TruncationStrategy(TruncationStrategyType.Auto) + { + LastMessages = 1234, + }, + }; + AgentConfigurationOptions agentConfiguration = new AgentConfigurationOptions("") + { + AgentModel = new OpenAIAgentModel("", new JSONAny()) + { + Endpoint = "", + }, + Instructions = "", + Tools = {new FunctionToolDefinition("") +{ +Description = "", +Parameters = new JSONSchema("", new Dictionary +{ +["key"] = default +}) +{ +Required = {""}, +}, +Strict = true, +Options = default, +Override = new AgentToolDefinitionOverride +{ +Name = "", +Description = "", +Parameters = default, +}, +}}, + ToolChoice = new AutoToolChoiceBehavior(new string[] { "" }), + }; + Response response = await client.RunAsync(new ChatMessage[] + { +new UserMessage(new AIContent[] +{ +new TextContent("") +{ +Annotations = {new Annotations("") +{ +ToolCallId = "", +JsonPath = "", +Url = "", +Start = 1234, +End = 1234, +}}, +} +}) +{ +UserId = "", +AgentId = "", +AgentRunId = "", +AuthorName = "", +CreatedAt = 1234L, +CompletedAt = 1234L, +} + }, agentId: "", conversationId: "", metadata: new Dictionary + { + ["key"] = "" + }, options: options, userId: "", agentConfiguration: agentConfiguration); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_Stream_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + input = new object[] + { +new +{ +role = "user", +content = new object[] +{ +new +{ +type = "text", +text = "", +} +}, +} + }, + }); + Response response = client.Stream(content); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_Stream_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + input = new object[] + { +new +{ +role = "user", +content = new object[] +{ +new +{ +type = "text", +text = "", +} +}, +} + }, + }); + Response response = await client.StreamAsync(content); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_Stream_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.Stream(new ChatMessage[] + { +new UserMessage(new AIContent[] +{ +new TextContent("") +}) + }); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_Stream_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.StreamAsync(new ChatMessage[] + { +new UserMessage(new AIContent[] +{ +new TextContent("") +}) + }); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_Stream_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + agentId = "", + input = new object[] + { +new +{ +role = "user", +content = new object[] +{ +new +{ +type = "text", +text = "", +annotations = new object[] +{ +new +{ +type = "", +ToolCallId = "", +jsonPath = "", +url = "", +start = 1234, +end = 1234, +} +}, +} +}, +userId = "", +agentId = "", +agentRunId = "", +authorName = "", +createdAt = 1234L, +completedAt = 1234L, +} + }, + conversationId = "", + metadata = new + { + key = "", + }, + options = new + { + truncationStrategy = new + { + type = "auto", + lastMessages = 1234, + }, + }, + userId = "", + agentConfiguration = new + { + displayName = "", + agentModel = new + { + provider = "openai", + options = new + { + temperature = 123.45F, + topP = 123.45F, + }, + id = "", + endpoint = "", + }, + instructions = "", + tools = new object[] + { +new Dictionary +{ +["type"] = "Function", +["name"] = "", +["description"] = "", +["parameters"] = new +{ +type = "", +properties = new {}, +required = new object[] +{ +"" +}, +}, +["strict"] = true, +["options"] = null, +["override"] = new +{ +name = "", +description = "", +} +} + }, + toolChoice = new + { + type = "auto", + toolNames = new object[] + { +"" + }, + }, + }, + }); + Response response = client.Stream(content); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_Stream_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + agentId = "", + input = new object[] + { +new +{ +role = "user", +content = new object[] +{ +new +{ +type = "text", +text = "", +annotations = new object[] +{ +new +{ +type = "", +ToolCallId = "", +jsonPath = "", +url = "", +start = 1234, +end = 1234, +} +}, +} +}, +userId = "", +agentId = "", +agentRunId = "", +authorName = "", +createdAt = 1234L, +completedAt = 1234L, +} + }, + conversationId = "", + metadata = new + { + key = "", + }, + options = new + { + truncationStrategy = new + { + type = "auto", + lastMessages = 1234, + }, + }, + userId = "", + agentConfiguration = new + { + displayName = "", + agentModel = new + { + provider = "openai", + options = new + { + temperature = 123.45F, + topP = 123.45F, + }, + id = "", + endpoint = "", + }, + instructions = "", + tools = new object[] + { +new Dictionary +{ +["type"] = "Function", +["name"] = "", +["description"] = "", +["parameters"] = new +{ +type = "", +properties = new {}, +required = new object[] +{ +"" +}, +}, +["strict"] = true, +["options"] = null, +["override"] = new +{ +name = "", +description = "", +} +} + }, + toolChoice = new + { + type = "auto", + toolNames = new object[] + { +"" + }, + }, + }, + }); + Response response = await client.StreamAsync(content); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_Stream_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + RunOptions options = new RunOptions + { + TruncationStrategy = new TruncationStrategy(TruncationStrategyType.Auto) + { + LastMessages = 1234, + }, + }; + AgentConfigurationOptions agentConfiguration = new AgentConfigurationOptions("") + { + AgentModel = new OpenAIAgentModel("", new JSONAny()) + { + Endpoint = "", + }, + Instructions = "", + Tools = {new FunctionToolDefinition("") +{ +Description = "", +Parameters = new JSONSchema("", new Dictionary +{ +["key"] = default +}) +{ +Required = {""}, +}, +Strict = true, +Options = default, +Override = new AgentToolDefinitionOverride +{ +Name = "", +Description = "", +Parameters = default, +}, +}}, + ToolChoice = new AutoToolChoiceBehavior(new string[] { "" }), + }; + Response response = client.Stream(new ChatMessage[] + { +new UserMessage(new AIContent[] +{ +new TextContent("") +{ +Annotations = {new Annotations("") +{ +ToolCallId = "", +JsonPath = "", +Url = "", +Start = 1234, +End = 1234, +}}, +} +}) +{ +UserId = "", +AgentId = "", +AgentRunId = "", +AuthorName = "", +CreatedAt = 1234L, +CompletedAt = 1234L, +} + }, agentId: "", conversationId: "", metadata: new Dictionary + { + ["key"] = "" + }, options: options, userId: "", agentConfiguration: agentConfiguration); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_Stream_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + RunOptions options = new RunOptions + { + TruncationStrategy = new TruncationStrategy(TruncationStrategyType.Auto) + { + LastMessages = 1234, + }, + }; + AgentConfigurationOptions agentConfiguration = new AgentConfigurationOptions("") + { + AgentModel = new OpenAIAgentModel("", new JSONAny()) + { + Endpoint = "", + }, + Instructions = "", + Tools = {new FunctionToolDefinition("") +{ +Description = "", +Parameters = new JSONSchema("", new Dictionary +{ +["key"] = default +}) +{ +Required = {""}, +}, +Strict = true, +Options = default, +Override = new AgentToolDefinitionOverride +{ +Name = "", +Description = "", +Parameters = default, +}, +}}, + ToolChoice = new AutoToolChoiceBehavior(new string[] { "" }), + }; + Response response = await client.StreamAsync(new ChatMessage[] + { +new UserMessage(new AIContent[] +{ +new TextContent("") +{ +Annotations = {new Annotations("") +{ +ToolCallId = "", +JsonPath = "", +Url = "", +Start = 1234, +End = 1234, +}}, +} +}) +{ +UserId = "", +AgentId = "", +AgentRunId = "", +AuthorName = "", +CreatedAt = 1234L, +CompletedAt = 1234L, +} + }, agentId: "", conversationId: "", metadata: new Dictionary + { + ["key"] = "" + }, options: options, userId: "", agentConfiguration: agentConfiguration); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Run_GetRun_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetRun("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("runId").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Run_GetRun_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetRunAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("runId").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Run_GetRun_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetRun(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Run_GetRun_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetRunAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Run_GetRun_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetRun("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("runId").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("lastMessages").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("provider").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("endpoint").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("instructions").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("toolChoice").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("store").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokenDetails").GetProperty("cachedTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokenDetails").GetProperty("reasoningTokens").ToString()); + Console.WriteLine(result.GetProperty("incompleteDetails").GetProperty("reason").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Run_GetRun_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetRunAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("runId").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("lastMessages").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("provider").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("endpoint").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("instructions").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("toolChoice").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("store").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokenDetails").GetProperty("cachedTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokenDetails").GetProperty("reasoningTokens").ToString()); + Console.WriteLine(result.GetProperty("incompleteDetails").GetProperty("reason").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Run_GetRun_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetRun(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Run_GetRun_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetRunAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_GetRunInputs_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetRunInputs("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_GetRunInputs_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetRunInputsAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_GetRunInputs_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetRunInputs(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_GetRunInputs_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetRunInputsAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_GetRunInputs_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetRunInputs("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("options").GetProperty("truncationStrategy").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("options").GetProperty("truncationStrategy").GetProperty("lastMessages").ToString()); + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("provider").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("endpoint").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("instructions").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("toolChoice").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_GetRunInputs_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetRunInputsAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("input")[0].GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("options").GetProperty("truncationStrategy").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("options").GetProperty("truncationStrategy").GetProperty("lastMessages").ToString()); + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("provider").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("endpoint").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("instructions").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); + Console.WriteLine(result.GetProperty("agentConfiguration").GetProperty("toolChoice").GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Agents_GetRunInputs_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetRunInputs(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Agents_GetRunInputs_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetRunInputsAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Run_GetRuns_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + foreach (BinaryData item in client.GetRuns(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("runId").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Run_GetRuns_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + await foreach (BinaryData item in client.GetRunsAsync(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("runId").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Run_GetRuns_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + foreach (Run item in client.GetRuns()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Run_GetRuns_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + await foreach (Run item in client.GetRunsAsync()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Run_GetRuns_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + foreach (BinaryData item in client.GetRuns(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("runId").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("lastMessages").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("provider").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("endpoint").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("instructions").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("toolChoice").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("store").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokenDetails").GetProperty("cachedTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokenDetails").GetProperty("reasoningTokens").ToString()); + Console.WriteLine(result.GetProperty("incompleteDetails").GetProperty("reason").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Run_GetRuns_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + await foreach (BinaryData item in client.GetRunsAsync(null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("runId").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("input")[0].GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("metadata").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("options").GetProperty("truncationStrategy").GetProperty("lastMessages").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("provider").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("endpoint").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("stringValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("intValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("floatValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("boolValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("agentModel").GetProperty("options").GetProperty("nullValue").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("instructions").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("options").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("tools")[0].GetProperty("override").GetProperty("parameters").GetProperty("required")[0].ToString()); + Console.WriteLine(result.GetProperty("runInputs").GetProperty("agentConfiguration").GetProperty("toolChoice").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("store").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("output")[0].GetProperty("completedAt").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("totalTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("inputTokenDetails").GetProperty("cachedTokens").ToString()); + Console.WriteLine(result.GetProperty("usage").GetProperty("outputTokenDetails").GetProperty("reasoningTokens").ToString()); + Console.WriteLine(result.GetProperty("incompleteDetails").GetProperty("reason").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Run_GetRuns_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + foreach (Run item in client.GetRuns()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Run_GetRuns_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Agents client = new AIProjectClient(endpoint, credential).GetAgentsClient(apiVersion: "2025-05-01-preview"); + + await foreach (Run item in client.GetRunsAsync()) + { + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Connections.cs b/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Connections.cs new file mode 100644 index 000000000000..e129236c71ad --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Connections.cs @@ -0,0 +1,254 @@ +// 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.Identity; +using NUnit.Framework; + +namespace Azure.AI.Projects.OneDP.Samples +{ + public partial class Samples_Connections + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Connection_GetConnection_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetConnection("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Connection_GetConnection_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetConnectionAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Connection_GetConnection_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetConnection(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Connection_GetConnection_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetConnectionAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Connection_GetConnection_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetConnection("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Connection_GetConnection_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetConnectionAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Connection_GetConnection_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetConnection(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Connection_GetConnection_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetConnectionAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Connection_GetConnections_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + + foreach (BinaryData item in client.GetConnections(null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Connection_GetConnections_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + + await foreach (BinaryData item in client.GetConnectionsAsync(null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Connection_GetConnections_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + + foreach (Connection item in client.GetConnections()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Connection_GetConnections_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + + await foreach (Connection item in client.GetConnectionsAsync()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Connection_GetConnections_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + + foreach (BinaryData item in client.GetConnections("AzureOpenAI", 1234, 1234, 1234, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Connection_GetConnections_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + + await foreach (BinaryData item in client.GetConnectionsAsync("AzureOpenAI", 1234, 1234, 1234, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("target").ToString()); + Console.WriteLine(result.GetProperty("metadata").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Connection_GetConnections_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + + foreach (Connection item in client.GetConnections(connectionType: ConnectionType.AzureOpenAI, maxCount: 1234, skip: 1234, maxpagesize: 1234)) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Connection_GetConnections_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Connections client = new AIProjectClient(endpoint, credential).GetConnectionsClient(apiVersion: "2025-05-01-preview"); + + await foreach (Connection item in client.GetConnectionsAsync(connectionType: ConnectionType.AzureOpenAI, maxCount: 1234, skip: 1234, maxpagesize: 1234)) + { + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Conversations.cs b/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Conversations.cs new file mode 100644 index 000000000000..8cfdce7e7043 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Conversations.cs @@ -0,0 +1,924 @@ +// 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 System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AI.Projects.OneDP.Samples +{ + public partial class Samples_Conversations + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Conversations_CreateConversation_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + messages = new object[] + { +new +{ +role = "user", +content = new object[] +{ +new +{ +type = "text", +text = "", +} +}, +} + }, + }); + Response response = client.CreateConversation(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Conversations_CreateConversation_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + messages = new object[] + { +new +{ +role = "user", +content = new object[] +{ +new +{ +type = "text", +text = "", +} +}, +} + }, + }); + Response response = await client.CreateConversationAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Conversations_CreateConversation_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.CreateConversation(new ChatMessage[] + { +new UserMessage(new AIContent[] +{ +new TextContent("") +}) + }); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Conversations_CreateConversation_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.CreateConversationAsync(new ChatMessage[] + { +new UserMessage(new AIContent[] +{ +new TextContent("") +}) + }); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Conversations_CreateConversation_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + messages = new object[] + { +new +{ +role = "user", +content = new object[] +{ +new +{ +type = "text", +text = "", +annotations = new object[] +{ +new +{ +type = "", +ToolCallId = "", +jsonPath = "", +url = "", +start = 1234, +end = 1234, +} +}, +} +}, +userId = "", +agentId = "", +agentRunId = "", +authorName = "", +createdAt = 1234L, +completedAt = 1234L, +} + }, + }); + Response response = client.CreateConversation(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("completedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Conversations_CreateConversation_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + messages = new object[] + { +new +{ +role = "user", +content = new object[] +{ +new +{ +type = "text", +text = "", +annotations = new object[] +{ +new +{ +type = "", +ToolCallId = "", +jsonPath = "", +url = "", +start = 1234, +end = 1234, +} +}, +} +}, +userId = "", +agentId = "", +agentRunId = "", +authorName = "", +createdAt = 1234L, +completedAt = 1234L, +} + }, + }); + Response response = await client.CreateConversationAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("completedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Conversations_CreateConversation_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.CreateConversation(new ChatMessage[] + { +new UserMessage(new AIContent[] +{ +new TextContent("") +{ +Annotations = {new Annotations("") +{ +ToolCallId = "", +JsonPath = "", +Url = "", +Start = 1234, +End = 1234, +}}, +} +}) +{ +UserId = "", +AgentId = "", +AgentRunId = "", +AuthorName = "", +CreatedAt = 1234L, +CompletedAt = 1234L, +} + }); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Conversations_CreateConversation_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.CreateConversationAsync(new ChatMessage[] + { +new UserMessage(new AIContent[] +{ +new TextContent("") +{ +Annotations = {new Annotations("") +{ +ToolCallId = "", +JsonPath = "", +Url = "", +Start = 1234, +End = 1234, +}}, +} +}) +{ +UserId = "", +AgentId = "", +AgentRunId = "", +AuthorName = "", +CreatedAt = 1234L, +CompletedAt = 1234L, +} + }); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Conversations_GetConversation_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetConversation("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Conversations_GetConversation_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetConversationAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Conversations_GetConversation_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetConversation(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Conversations_GetConversation_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetConversationAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Conversations_GetConversation_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetConversation("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("completedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Conversations_GetConversation_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetConversationAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("completedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Conversations_GetConversation_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetConversation(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Conversations_GetConversation_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetConversationAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Conversations_UpdateConversation_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + messages = new object[] + { +new +{ +role = "user", +content = new object[] +{ +new +{ +type = "text", +text = "", +} +}, +} + }, + }); + Response response = client.UpdateConversation("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Conversations_UpdateConversation_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + messages = new object[] + { +new +{ +role = "user", +content = new object[] +{ +new +{ +type = "text", +text = "", +} +}, +} + }, + }); + Response response = await client.UpdateConversationAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Conversations_UpdateConversation_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Conversation body = new Conversation(new ChatMessage[] + { +new UserMessage(new AIContent[] +{ +new TextContent("") +}) + }); + Response response = client.UpdateConversation("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Conversations_UpdateConversation_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Conversation body = new Conversation(new ChatMessage[] + { +new UserMessage(new AIContent[] +{ +new TextContent("") +}) + }); + Response response = await client.UpdateConversationAsync("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Conversations_UpdateConversation_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + messages = new object[] + { +new +{ +role = "user", +content = new object[] +{ +new +{ +type = "text", +text = "", +annotations = new object[] +{ +new +{ +type = "", +ToolCallId = "", +jsonPath = "", +url = "", +start = 1234, +end = 1234, +} +}, +} +}, +userId = "", +agentId = "", +agentRunId = "", +authorName = "", +createdAt = 1234L, +completedAt = 1234L, +} + }, + }); + Response response = client.UpdateConversation("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("completedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Conversations_UpdateConversation_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + messages = new object[] + { +new +{ +role = "user", +content = new object[] +{ +new +{ +type = "text", +text = "", +annotations = new object[] +{ +new +{ +type = "", +ToolCallId = "", +jsonPath = "", +url = "", +start = 1234, +end = 1234, +} +}, +} +}, +userId = "", +agentId = "", +agentRunId = "", +authorName = "", +createdAt = 1234L, +completedAt = 1234L, +} + }, + }); + Response response = await client.UpdateConversationAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("messages")[0].GetProperty("completedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Conversations_UpdateConversation_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Conversation body = new Conversation(new ChatMessage[] + { +new UserMessage(new AIContent[] +{ +new TextContent("") +{ +Annotations = {new Annotations("") +{ +ToolCallId = "", +JsonPath = "", +Url = "", +Start = 1234, +End = 1234, +}}, +} +}) +{ +UserId = "", +AgentId = "", +AgentRunId = "", +AuthorName = "", +CreatedAt = 1234L, +CompletedAt = 1234L, +} + }); + Response response = client.UpdateConversation("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Conversations_UpdateConversation_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Conversation body = new Conversation(new ChatMessage[] + { +new UserMessage(new AIContent[] +{ +new TextContent("") +{ +Annotations = {new Annotations("") +{ +ToolCallId = "", +JsonPath = "", +Url = "", +Start = 1234, +End = 1234, +}}, +} +}) +{ +UserId = "", +AgentId = "", +AgentRunId = "", +AuthorName = "", +CreatedAt = 1234L, +CompletedAt = 1234L, +} + }); + Response response = await client.UpdateConversationAsync("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Conversations_DeleteConversation_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.DeleteConversation(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Conversations_DeleteConversation_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.DeleteConversationAsync(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Conversations_DeleteConversation_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.DeleteConversation(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Conversations_DeleteConversation_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.DeleteConversationAsync(""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Conversations_GetConversations_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetConversations(null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("role").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Conversations_GetConversations_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetConversationsAsync(null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("role").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Conversations_GetConversations_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response> response = client.GetConversations(); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Conversations_GetConversations_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response> response = await client.GetConversationsAsync(); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Conversations_GetConversations_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetConversations(null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("userId").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("role").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("completedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Conversations_GetConversations_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetConversationsAsync(null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("userId").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("agentId").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("messageId").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("agentRunId").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("conversationId").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("role").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("authorName").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("createdAt").ToString()); + Console.WriteLine(result[0].GetProperty("messages")[0].GetProperty("completedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Conversations_GetConversations_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response> response = client.GetConversations(); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Conversations_GetConversations_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Conversations client = new AIProjectClient(endpoint, credential).GetConversationsClient(apiVersion: "2025-05-01-preview"); + + Response> response = await client.GetConversationsAsync(); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Datasets.cs b/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Datasets.cs new file mode 100644 index 000000000000..403b4067e73b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Datasets.cs @@ -0,0 +1,1121 @@ +// 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.Projects.OneDP.Samples +{ + public partial class Samples_Datasets + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetVersion_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetVersion("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetVersion_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetVersionAsync("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetVersion_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetVersion("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetVersion_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetVersionAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetVersion_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetVersion("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetVersion_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetVersionAsync("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetVersion_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetVersion("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetVersion_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetVersionAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_DeleteVersion_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.DeleteVersion("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_DeleteVersion_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.DeleteVersionAsync("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_DeleteVersion_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.DeleteVersion("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_DeleteVersion_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.DeleteVersionAsync("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_Create_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "uri_file", + openAIPurpose = "", + datasetUri = "", + }); + Response response = client.Create("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_Create_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "uri_file", + openAIPurpose = "", + datasetUri = "", + }); + Response response = await client.CreateAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_Create_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + DatasetVersion body = new FileDatasetVersion("", ""); + Response response = client.Create("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_Create_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + DatasetVersion body = new FileDatasetVersion("", ""); + Response response = await client.CreateAsync("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_Create_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "uri_file", + openAIPurpose = "", + datasetUri = "", + stage = "", + description = "", + tags = new + { + key = "", + }, + }); + Response response = client.Create("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_Create_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "uri_file", + openAIPurpose = "", + datasetUri = "", + stage = "", + description = "", + tags = new + { + key = "", + }, + }); + Response response = await client.CreateAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_Create_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + DatasetVersion body = new FileDatasetVersion("", "") + { + Stage = "", + Description = "", + Tags = +{ +["key"] = "" +}, + }; + Response response = client.Create("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_Create_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + DatasetVersion body = new FileDatasetVersion("", "") + { + Stage = "", + Description = "", + Tags = +{ +["key"] = "" +}, + }; + Response response = await client.CreateAsync("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_CreateVersion_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "uri_file", + openAIPurpose = "", + datasetUri = "", + }); + Response response = client.CreateVersion("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_CreateVersion_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "uri_file", + openAIPurpose = "", + datasetUri = "", + }); + Response response = await client.CreateVersionAsync("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_CreateVersion_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + DatasetVersion body = new FileDatasetVersion("", ""); + Response response = client.CreateVersion("", "", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_CreateVersion_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + DatasetVersion body = new FileDatasetVersion("", ""); + Response response = await client.CreateVersionAsync("", "", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_CreateVersion_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "uri_file", + openAIPurpose = "", + datasetUri = "", + stage = "", + description = "", + tags = new + { + key = "", + }, + }); + Response response = client.CreateVersion("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_CreateVersion_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "uri_file", + openAIPurpose = "", + datasetUri = "", + stage = "", + description = "", + tags = new + { + key = "", + }, + }); + Response response = await client.CreateVersionAsync("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_CreateVersion_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + DatasetVersion body = new FileDatasetVersion("", "") + { + Stage = "", + Description = "", + Tags = +{ +["key"] = "" +}, + }; + Response response = client.CreateVersion("", "", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_CreateVersion_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + DatasetVersion body = new FileDatasetVersion("", "") + { + Stage = "", + Description = "", + Tags = +{ +["key"] = "" +}, + }; + Response response = await client.CreateVersionAsync("", "", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_StartPendingUpload_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + pendingUploadType = "TemporaryBlobReference", + }); + Response response = client.StartPendingUpload("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("blobUri").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("storageAccountArmId").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("sasToken").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_StartPendingUpload_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + pendingUploadType = "TemporaryBlobReference", + }); + Response response = await client.StartPendingUploadAsync("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("blobUri").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("storageAccountArmId").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("sasToken").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_StartPendingUpload_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + PendingUploadRequest body = new PendingUploadRequest(); + Response response = client.StartPendingUpload("", "", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_StartPendingUpload_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + PendingUploadRequest body = new PendingUploadRequest(); + Response response = await client.StartPendingUploadAsync("", "", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_StartPendingUpload_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + pendingUploadId = "", + connectionName = "", + pendingUploadType = "TemporaryBlobReference", + }); + Response response = client.StartPendingUpload("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("blobUri").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("storageAccountArmId").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("sasToken").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); + Console.WriteLine(result.GetProperty("datasetVersion").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_StartPendingUpload_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + pendingUploadId = "", + connectionName = "", + pendingUploadType = "TemporaryBlobReference", + }); + Response response = await client.StartPendingUploadAsync("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("blobUri").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("storageAccountArmId").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("sasToken").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); + Console.WriteLine(result.GetProperty("datasetVersion").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_StartPendingUpload_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + PendingUploadRequest body = new PendingUploadRequest + { + PendingUploadId = "", + ConnectionName = "", + }; + Response response = client.StartPendingUpload("", "", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_StartPendingUpload_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + PendingUploadRequest body = new PendingUploadRequest + { + PendingUploadId = "", + ConnectionName = "", + }; + Response response = await client.StartPendingUploadAsync("", "", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_StartPendingUploadAutoIncrement_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + pendingUploadType = "TemporaryBlobReference", + }); + Response response = client.StartPendingUploadAutoIncrement("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("blobUri").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("storageAccountArmId").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("sasToken").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_StartPendingUploadAutoIncrement_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + pendingUploadType = "TemporaryBlobReference", + }); + Response response = await client.StartPendingUploadAutoIncrementAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("blobUri").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("storageAccountArmId").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("sasToken").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_StartPendingUploadAutoIncrement_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.StartPendingUploadAutoIncrement("", PendingUploadType.TemporaryBlobReference); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_StartPendingUploadAutoIncrement_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.StartPendingUploadAutoIncrementAsync("", PendingUploadType.TemporaryBlobReference); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_StartPendingUploadAutoIncrement_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + pendingUploadId = "", + connectionName = "", + pendingUploadType = "TemporaryBlobReference", + }); + Response response = client.StartPendingUploadAutoIncrement("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("blobUri").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("storageAccountArmId").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("sasToken").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); + Console.WriteLine(result.GetProperty("datasetVersion").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_StartPendingUploadAutoIncrement_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + pendingUploadId = "", + connectionName = "", + pendingUploadType = "TemporaryBlobReference", + }); + Response response = await client.StartPendingUploadAutoIncrementAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("blobUri").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("storageAccountArmId").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("sasToken").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("blobReferenceForConsumption").GetProperty("credential").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadId").ToString()); + Console.WriteLine(result.GetProperty("datasetVersion").ToString()); + Console.WriteLine(result.GetProperty("pendingUploadType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_StartPendingUploadAutoIncrement_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.StartPendingUploadAutoIncrement("", PendingUploadType.TemporaryBlobReference, pendingUploadId: "", connectionName: ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_StartPendingUploadAutoIncrement_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.StartPendingUploadAutoIncrementAsync("", PendingUploadType.TemporaryBlobReference, pendingUploadId: "", connectionName: ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetVersions_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + foreach (BinaryData item in client.GetVersions("", null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetVersions_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + await foreach (BinaryData item in client.GetVersionsAsync("", null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetVersions_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + foreach (DatasetVersion item in client.GetVersions("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetVersions_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + await foreach (DatasetVersion item in client.GetVersionsAsync("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetVersions_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + foreach (BinaryData item in client.GetVersions("", 1234, "", "", "ActiveOnly", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetVersions_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + await foreach (BinaryData item in client.GetVersionsAsync("", 1234, "", "", "ActiveOnly", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Datasets_GetVersions_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + foreach (DatasetVersion item in client.GetVersions("", maxCount: 1234, skip: "", tags: "", listViewType: ListViewType.ActiveOnly)) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Datasets_GetVersions_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + await foreach (DatasetVersion item in client.GetVersionsAsync("", maxCount: 1234, skip: "", tags: "", listViewType: ListViewType.ActiveOnly)) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_DatasetVersion_GetLatests_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + foreach (BinaryData item in client.GetLatests(null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_DatasetVersion_GetLatests_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + await foreach (BinaryData item in client.GetLatestsAsync(null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_DatasetVersion_GetLatests_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + foreach (DatasetVersion item in client.GetLatests()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_DatasetVersion_GetLatests_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + await foreach (DatasetVersion item in client.GetLatestsAsync()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_DatasetVersion_GetLatests_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + foreach (BinaryData item in client.GetLatests(1234, "", "", "ActiveOnly", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_DatasetVersion_GetLatests_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + await foreach (BinaryData item in client.GetLatestsAsync(1234, "", "", "ActiveOnly", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("datasetUri").ToString()); + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("isReference").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_DatasetVersion_GetLatests_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + foreach (DatasetVersion item in client.GetLatests(maxCount: 1234, skip: "", tags: "", listViewType: ListViewType.ActiveOnly)) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_DatasetVersion_GetLatests_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Datasets client = new AIProjectClient(endpoint, credential).GetDatasetsClient(apiVersion: "2025-05-01-preview"); + + await foreach (DatasetVersion item in client.GetLatestsAsync(maxCount: 1234, skip: "", tags: "", listViewType: ListViewType.ActiveOnly)) + { + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Deployments.cs b/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Deployments.cs new file mode 100644 index 000000000000..99f680df60db --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Deployments.cs @@ -0,0 +1,238 @@ +// 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.Identity; +using NUnit.Framework; + +namespace Azure.AI.Projects.OneDP.Samples +{ + public partial class Samples_Deployments + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Deployment_GetDeployment_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetDeployment("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Deployment_GetDeployment_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetDeploymentAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Deployment_GetDeployment_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetDeployment(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Deployment_GetDeployment_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetDeploymentAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Deployment_GetDeployment_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetDeployment("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Deployment_GetDeployment_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetDeploymentAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Deployment_GetDeployment_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetDeployment(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Deployment_GetDeployment_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetDeploymentAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Deployment_GetDeployments_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + + foreach (BinaryData item in client.GetDeployments(null, null, null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Deployment_GetDeployments_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + + await foreach (BinaryData item in client.GetDeploymentsAsync(null, null, null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Deployment_GetDeployments_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + + foreach (Deployment item in client.GetDeployments()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Deployment_GetDeployments_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + + await foreach (Deployment item in client.GetDeploymentsAsync()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Deployment_GetDeployments_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + + foreach (BinaryData item in client.GetDeployments("", "", true, 1234, 1234, 1234, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Deployment_GetDeployments_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + + await foreach (BinaryData item in client.GetDeploymentsAsync("", "", true, 1234, 1234, 1234, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Deployment_GetDeployments_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + + foreach (Deployment item in client.GetDeployments(modelPublisher: "", modelName: "", includeConnectionModels: true, maxCount: 1234, skip: 1234, maxpagesize: 1234)) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Deployment_GetDeployments_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Deployments client = new AIProjectClient(endpoint, credential).GetDeploymentsClient(apiVersion: "2025-05-01-preview"); + + await foreach (Deployment item in client.GetDeploymentsAsync(modelPublisher: "", modelName: "", includeConnectionModels: true, maxCount: 1234, skip: 1234, maxpagesize: 1234)) + { + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Evaluations.cs b/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Evaluations.cs new file mode 100644 index 000000000000..f2acffee5fbb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Evaluations.cs @@ -0,0 +1,554 @@ +// 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 System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AI.Projects.OneDP.Samples +{ + public partial class Samples_Evaluations + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluation_GetEvaluation_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetEvaluation("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluation_GetEvaluation_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetEvaluationAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluation_GetEvaluation_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetEvaluation(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluation_GetEvaluation_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetEvaluationAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluation_GetEvaluation_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetEvaluation("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("initParams").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("dataMapping").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluation_GetEvaluation_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetEvaluationAsync("", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("initParams").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("dataMapping").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluation_GetEvaluation_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetEvaluation(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluation_GetEvaluation_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetEvaluationAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluations_CreateRun_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + data = new + { + type = "dataset", + id = "", + }, + evaluators = new + { + key = new + { + id = "", + }, + }, + }); + Response response = client.CreateRun(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluations_CreateRun_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + data = new + { + type = "dataset", + id = "", + }, + evaluators = new + { + key = new + { + id = "", + }, + }, + }); + Response response = await client.CreateRunAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluations_CreateRun_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + Evaluation evaluation = new Evaluation(new InputDataset(""), new Dictionary + { + ["key"] = new EvaluatorConfiguration("") + }); + Response response = client.CreateRun(evaluation); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluations_CreateRun_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + Evaluation evaluation = new Evaluation(new InputDataset(""), new Dictionary + { + ["key"] = new EvaluatorConfiguration("") + }); + Response response = await client.CreateRunAsync(evaluation); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluations_CreateRun_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + data = new + { + type = "dataset", + id = "", + }, + displayName = "", + description = "", + tags = new + { + key = "", + }, + properties = new + { + key = "", + }, + evaluators = new + { + key = new + { + id = "", + initParams = new + { + key = new object(), + }, + dataMapping = new + { + key = "", + }, + }, + }, + }); + Response response = client.CreateRun(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("initParams").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("dataMapping").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluations_CreateRun_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + data = new + { + type = "dataset", + id = "", + }, + displayName = "", + description = "", + tags = new + { + key = "", + }, + properties = new + { + key = "", + }, + evaluators = new + { + key = new + { + id = "", + initParams = new + { + key = new object(), + }, + dataMapping = new + { + key = "", + }, + }, + }, + }); + Response response = await client.CreateRunAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("initParams").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("dataMapping").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluations_CreateRun_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + Evaluation evaluation = new Evaluation(new InputDataset(""), new Dictionary + { + ["key"] = new EvaluatorConfiguration("") + { + InitParams = +{ +["key"] = BinaryData.FromObjectAsJson(new object()) +}, + DataMapping = +{ +["key"] = "" +}, + } + }) + { + DisplayName = "", + Description = "", + Tags = +{ +["key"] = "" +}, + Properties = +{ +["key"] = "" +}, + }; + Response response = client.CreateRun(evaluation); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluations_CreateRun_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + Evaluation evaluation = new Evaluation(new InputDataset(""), new Dictionary + { + ["key"] = new EvaluatorConfiguration("") + { + InitParams = +{ +["key"] = BinaryData.FromObjectAsJson(new object()) +}, + DataMapping = +{ +["key"] = "" +}, + } + }) + { + DisplayName = "", + Description = "", + Tags = +{ +["key"] = "" +}, + Properties = +{ +["key"] = "" +}, + }; + Response response = await client.CreateRunAsync(evaluation); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluation_GetEvaluations_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + foreach (BinaryData item in client.GetEvaluations(null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluation_GetEvaluations_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + await foreach (BinaryData item in client.GetEvaluationsAsync(null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluation_GetEvaluations_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + foreach (Evaluation item in client.GetEvaluations()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluation_GetEvaluations_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + await foreach (Evaluation item in client.GetEvaluationsAsync()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluation_GetEvaluations_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + foreach (BinaryData item in client.GetEvaluations(1234, 1234, 1234, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("initParams").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("dataMapping").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluation_GetEvaluations_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + await foreach (BinaryData item in client.GetEvaluationsAsync(1234, 1234, 1234, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("data").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("displayName").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("status").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("properties").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("initParams").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("evaluators").GetProperty("").GetProperty("dataMapping").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Evaluation_GetEvaluations_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + foreach (Evaluation item in client.GetEvaluations(maxCount: 1234, skip: 1234, maxpagesize: 1234)) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Evaluation_GetEvaluations_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Evaluations client = new AIProjectClient(endpoint, credential).GetEvaluationsClient(apiVersion: "2025-05-01-preview"); + + await foreach (Evaluation item in client.GetEvaluationsAsync(maxCount: 1234, skip: 1234, maxpagesize: 1234)) + { + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Indexes.cs b/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Indexes.cs new file mode 100644 index 000000000000..1d7c0d8a1aeb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Indexes.cs @@ -0,0 +1,787 @@ +// 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.Projects.OneDP.Samples +{ + public partial class Samples_Indexes + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_GetVersion_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetVersion("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_GetVersion_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetVersionAsync("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_GetVersion_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetVersion("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_GetVersion_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetVersionAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_GetVersion_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetVersion("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_GetVersion_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetVersionAsync("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_GetVersion_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetVersion("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_GetVersion_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetVersionAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_DeleteVersion_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Response response = client.DeleteVersion("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_DeleteVersion_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.DeleteVersionAsync("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_DeleteVersion_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Response response = client.DeleteVersion("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_DeleteVersion_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.DeleteVersionAsync("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_Create_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "AzureSearch", + connectionName = "", + indexName = "", + }); + Response response = client.Create("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_Create_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "AzureSearch", + connectionName = "", + indexName = "", + }); + Response response = await client.CreateAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_Create_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Index body = new AzureAISearchIndex("", ""); + Response response = client.Create("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_Create_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Index body = new AzureAISearchIndex("", ""); + Response response = await client.CreateAsync("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_Create_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "AzureSearch", + connectionName = "", + indexName = "", + stage = "", + description = "", + tags = new + { + key = "", + }, + }); + Response response = client.Create("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_Create_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "AzureSearch", + connectionName = "", + indexName = "", + stage = "", + description = "", + tags = new + { + key = "", + }, + }); + Response response = await client.CreateAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_Create_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Index body = new AzureAISearchIndex("", "") + { + Stage = "", + Description = "", + Tags = +{ +["key"] = "" +}, + }; + Response response = client.Create("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_Create_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Index body = new AzureAISearchIndex("", "") + { + Stage = "", + Description = "", + Tags = +{ +["key"] = "" +}, + }; + Response response = await client.CreateAsync("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_CreateVersion_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "AzureSearch", + connectionName = "", + indexName = "", + }); + Response response = client.CreateVersion("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_CreateVersion_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "AzureSearch", + connectionName = "", + indexName = "", + }); + Response response = await client.CreateVersionAsync("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_CreateVersion_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Index body = new AzureAISearchIndex("", ""); + Response response = client.CreateVersion("", "", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_CreateVersion_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Index body = new AzureAISearchIndex("", ""); + Response response = await client.CreateVersionAsync("", "", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_CreateVersion_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "AzureSearch", + connectionName = "", + indexName = "", + stage = "", + description = "", + tags = new + { + key = "", + }, + }); + Response response = client.CreateVersion("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_CreateVersion_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + type = "AzureSearch", + connectionName = "", + indexName = "", + stage = "", + description = "", + tags = new + { + key = "", + }, + }); + Response response = await client.CreateVersionAsync("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_CreateVersion_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Index body = new AzureAISearchIndex("", "") + { + Stage = "", + Description = "", + Tags = +{ +["key"] = "" +}, + }; + Response response = client.CreateVersion("", "", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_CreateVersion_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + Index body = new AzureAISearchIndex("", "") + { + Stage = "", + Description = "", + Tags = +{ +["key"] = "" +}, + }; + Response response = await client.CreateVersionAsync("", "", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_GetVersions_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + foreach (BinaryData item in client.GetVersions("", null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_GetVersions_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + await foreach (BinaryData item in client.GetVersionsAsync("", null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_GetVersions_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + foreach (Index item in client.GetVersions("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_GetVersions_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + await foreach (Index item in client.GetVersionsAsync("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_GetVersions_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + foreach (BinaryData item in client.GetVersions("", 1234, "", "", "ActiveOnly", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_GetVersions_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + await foreach (BinaryData item in client.GetVersionsAsync("", 1234, "", "", "ActiveOnly", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Indexes_GetVersions_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + foreach (Index item in client.GetVersions("", maxCount: 1234, skip: "", tags: "", listViewType: ListViewType.ActiveOnly)) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Indexes_GetVersions_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + await foreach (Index item in client.GetVersionsAsync("", maxCount: 1234, skip: "", tags: "", listViewType: ListViewType.ActiveOnly)) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Index_GetLatests_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + foreach (BinaryData item in client.GetLatests(null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Index_GetLatests_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + await foreach (BinaryData item in client.GetLatestsAsync(null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Index_GetLatests_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + foreach (Index item in client.GetLatests()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Index_GetLatests_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + await foreach (Index item in client.GetLatestsAsync()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Index_GetLatests_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + foreach (BinaryData item in client.GetLatests(1234, "", "", "ActiveOnly", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Index_GetLatests_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + await foreach (BinaryData item in client.GetLatestsAsync(1234, "", "", "ActiveOnly", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("stage").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("version").ToString()); + Console.WriteLine(result.GetProperty("description").ToString()); + Console.WriteLine(result.GetProperty("tags").GetProperty("").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Index_GetLatests_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + foreach (Index item in client.GetLatests(maxCount: 1234, skip: "", tags: "", listViewType: ListViewType.ActiveOnly)) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Index_GetLatests_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Indexes client = new AIProjectClient(endpoint, credential).GetIndexesClient(apiVersion: "2025-05-01-preview"); + + await foreach (Index item in client.GetLatestsAsync(maxCount: 1234, skip: "", tags: "", listViewType: ListViewType.ActiveOnly)) + { + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Messages.cs b/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Messages.cs new file mode 100644 index 000000000000..b5d23611dddc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/tests/Generated/Samples/Samples_Messages.cs @@ -0,0 +1,851 @@ +// 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.Projects.OneDP.Samples +{ + public partial class Samples_Messages + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Messages_SendMessage_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + role = "user", + content = new object[] + { +new +{ +type = "text", +text = "", +} + }, + }); + Response response = client.SendMessage("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Messages_SendMessage_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + role = "user", + content = new object[] + { +new +{ +type = "text", +text = "", +} + }, + }); + Response response = await client.SendMessageAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Messages_SendMessage_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + ChatMessage body = new UserMessage(new AIContent[] + { +new TextContent("") + }); + Response response = client.SendMessage("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Messages_SendMessage_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + ChatMessage body = new UserMessage(new AIContent[] + { +new TextContent("") + }); + Response response = await client.SendMessageAsync("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Messages_SendMessage_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + role = "user", + content = new object[] + { +new +{ +type = "text", +text = "", +annotations = new object[] +{ +new +{ +type = "", +ToolCallId = "", +jsonPath = "", +url = "", +start = 1234, +end = 1234, +} +}, +} + }, + userId = "", + agentId = "", + agentRunId = "", + authorName = "", + createdAt = 1234L, + completedAt = 1234L, + }); + Response response = client.SendMessage("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Messages_SendMessage_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + role = "user", + content = new object[] + { +new +{ +type = "text", +text = "", +annotations = new object[] +{ +new +{ +type = "", +ToolCallId = "", +jsonPath = "", +url = "", +start = 1234, +end = 1234, +} +}, +} + }, + userId = "", + agentId = "", + agentRunId = "", + authorName = "", + createdAt = 1234L, + completedAt = 1234L, + }); + Response response = await client.SendMessageAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Messages_SendMessage_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + ChatMessage body = new UserMessage(new AIContent[] + { +new TextContent("") +{ +Annotations = {new Annotations("") +{ +ToolCallId = "", +JsonPath = "", +Url = "", +Start = 1234, +End = 1234, +}}, +} + }) + { + UserId = "", + AgentId = "", + AgentRunId = "", + AuthorName = "", + CreatedAt = 1234L, + CompletedAt = 1234L, + }; + Response response = client.SendMessage("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Messages_SendMessage_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + ChatMessage body = new UserMessage(new AIContent[] + { +new TextContent("") +{ +Annotations = {new Annotations("") +{ +ToolCallId = "", +JsonPath = "", +Url = "", +Start = 1234, +End = 1234, +}}, +} + }) + { + UserId = "", + AgentId = "", + AgentRunId = "", + AuthorName = "", + CreatedAt = 1234L, + CompletedAt = 1234L, + }; + Response response = await client.SendMessageAsync("", body); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ChatMessage_GetMessage_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetMessage("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ChatMessage_GetMessage_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetMessageAsync("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ChatMessage_GetMessage_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetMessage("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ChatMessage_GetMessage_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetMessageAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ChatMessage_GetMessage_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetMessage("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ChatMessage_GetMessage_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetMessageAsync("", "", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ChatMessage_GetMessage_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + Response response = client.GetMessage("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ChatMessage_GetMessage_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.GetMessageAsync("", ""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ChatMessage_UpdateMessage_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + role = "user", + content = new object[] + { +new +{ +type = "text", +text = "", +} + }, + }); + Response response = client.UpdateMessage("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ChatMessage_UpdateMessage_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + role = "user", + content = new object[] + { +new +{ +type = "text", +text = "", +} + }, + }); + Response response = await client.UpdateMessageAsync("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ChatMessage_UpdateMessage_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + ChatMessage resource = new UserMessage(new AIContent[] + { +new TextContent("") + }); + Response response = client.UpdateMessage("", "", resource); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ChatMessage_UpdateMessage_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + ChatMessage resource = new UserMessage(new AIContent[] + { +new TextContent("") + }); + Response response = await client.UpdateMessageAsync("", "", resource); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ChatMessage_UpdateMessage_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + role = "user", + content = new object[] + { +new +{ +type = "text", +text = "", +annotations = new object[] +{ +new +{ +type = "", +ToolCallId = "", +jsonPath = "", +url = "", +start = 1234, +end = 1234, +} +}, +} + }, + userId = "", + agentId = "", + agentRunId = "", + authorName = "", + createdAt = 1234L, + completedAt = 1234L, + }); + Response response = client.UpdateMessage("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ChatMessage_UpdateMessage_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + role = "user", + content = new object[] + { +new +{ +type = "text", +text = "", +annotations = new object[] +{ +new +{ +type = "", +ToolCallId = "", +jsonPath = "", +url = "", +start = 1234, +end = 1234, +} +}, +} + }, + userId = "", + agentId = "", + agentRunId = "", + authorName = "", + createdAt = 1234L, + completedAt = 1234L, + }); + Response response = await client.UpdateMessageAsync("", "", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ChatMessage_UpdateMessage_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + ChatMessage resource = new UserMessage(new AIContent[] + { +new TextContent("") +{ +Annotations = {new Annotations("") +{ +ToolCallId = "", +JsonPath = "", +Url = "", +Start = 1234, +End = 1234, +}}, +} + }) + { + UserId = "", + AgentId = "", + AgentRunId = "", + AuthorName = "", + CreatedAt = 1234L, + CompletedAt = 1234L, + }; + Response response = client.UpdateMessage("", "", resource); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ChatMessage_UpdateMessage_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + ChatMessage resource = new UserMessage(new AIContent[] + { +new TextContent("") +{ +Annotations = {new Annotations("") +{ +ToolCallId = "", +JsonPath = "", +Url = "", +Start = 1234, +End = 1234, +}}, +} + }) + { + UserId = "", + AgentId = "", + AgentRunId = "", + AuthorName = "", + CreatedAt = 1234L, + CompletedAt = 1234L, + }; + Response response = await client.UpdateMessageAsync("", "", resource); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ChatMessage_DeleteMessage_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + Response response = client.DeleteMessage("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ChatMessage_DeleteMessage_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.DeleteMessageAsync("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ChatMessage_DeleteMessage_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + Response response = client.DeleteMessage("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ChatMessage_DeleteMessage_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + Response response = await client.DeleteMessageAsync("", ""); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ChatMessage_GetMessages_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + foreach (BinaryData item in client.GetMessages("", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ChatMessage_GetMessages_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + await foreach (BinaryData item in client.GetMessagesAsync("", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ChatMessage_GetMessages_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + foreach (ChatMessage item in client.GetMessages("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ChatMessage_GetMessages_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + await foreach (ChatMessage item in client.GetMessagesAsync("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ChatMessage_GetMessages_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + foreach (BinaryData item in client.GetMessages("", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ChatMessage_GetMessages_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + await foreach (BinaryData item in client.GetMessagesAsync("", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("userId").ToString()); + Console.WriteLine(result.GetProperty("agentId").ToString()); + Console.WriteLine(result.GetProperty("messageId").ToString()); + Console.WriteLine(result.GetProperty("agentRunId").ToString()); + Console.WriteLine(result.GetProperty("conversationId").ToString()); + Console.WriteLine(result.GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("content")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("authorName").ToString()); + Console.WriteLine(result.GetProperty("createdAt").ToString()); + Console.WriteLine(result.GetProperty("completedAt").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ChatMessage_GetMessages_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + foreach (ChatMessage item in client.GetMessages("")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ChatMessage_GetMessages_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Messages client = new AIProjectClient(endpoint, credential).GetMessagesClient(apiVersion: "2025-05-01-preview"); + + await foreach (ChatMessage item in client.GetMessagesAsync("")) + { + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OneDP/tsp-location.yaml b/sdk/ai/Azure.AI.Projects.OneDP/tsp-location.yaml new file mode 100644 index 000000000000..cf36cb7d3ce7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OneDP/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/ai/Azure.AI.Projects +commit: e0c3a83a86cc7030c8c952e0cd5f03975e026365 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/ai/ci.yml b/sdk/ai/ci.yml new file mode 100644 index 000000000000..055fe545a1f2 --- /dev/null +++ b/sdk/ai/ci.yml @@ -0,0 +1,35 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/ai + - sdk/ai/ci.yml + - sdk/ai/Azure.AI.Projects.OneDP + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/ai + - sdk/ai/ci.yml + - sdk/ai/Azure.AI.Projects.OneDP + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: ai + ArtifactName: packages + Artifacts: + - name: Azure.AI.Projects.OneDP + safeName: AzureAIProjectsOneDP