diff --git a/sdk/onlineexperimentation/ci.yml b/sdk/onlineexperimentation/ci.yml
new file mode 100644
index 000000000000..ee3c08960228
--- /dev/null
+++ b/sdk/onlineexperimentation/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/onlineexperimentation
+ - sdk/onlineexperimentation/ci.yml
+ - sdk/onlineexperimentation/Azure.Analytics.OnlineExperimentation
+
+pr:
+ branches:
+ include:
+ - main
+ - feature/*
+ - hotfix/*
+ - release/*
+ paths:
+ include:
+ - sdk/onlineexperimentation
+ - sdk/onlineexperimentation/ci.yml
+ - sdk/onlineexperimentation/Azure.Analytics.OnlineExperimentation
+
+extends:
+ template: /eng/pipelines/templates/stages/archetype-sdk-client.yml
+ parameters:
+ ServiceDirectory: onlineexperimentation
+ ArtifactName: packages
+ Artifacts:
+ - name: Azure.Analytics.OnlineExperimentation
+ safeName: AzureAnalyticsOnlineExperimentation
diff --git a/sdk/onlineexperimentation/onlineexperimentation/Azure.Analytics.OnlineExperimentation.sln b/sdk/onlineexperimentation/onlineexperimentation/Azure.Analytics.OnlineExperimentation.sln
new file mode 100644
index 000000000000..939ec6a0bab8
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/Azure.Analytics.OnlineExperimentation.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.Analytics.OnlineExperimentation", "src\Azure.Analytics.OnlineExperimentation.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Analytics.OnlineExperimentation.Tests", "tests\Azure.Analytics.OnlineExperimentation.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/onlineexperimentation/onlineexperimentation/CHANGELOG.md b/sdk/onlineexperimentation/onlineexperimentation/CHANGELOG.md
new file mode 100644
index 000000000000..8b33f0fedccc
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/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/onlineexperimentation/onlineexperimentation/Directory.Build.props b/sdk/onlineexperimentation/onlineexperimentation/Directory.Build.props
new file mode 100644
index 000000000000..63bd836ad44b
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/Directory.Build.props
@@ -0,0 +1,6 @@
+
+
+
+
diff --git a/sdk/onlineexperimentation/onlineexperimentation/README.md b/sdk/onlineexperimentation/onlineexperimentation/README.md
new file mode 100644
index 000000000000..2332fdf68c52
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/README.md
@@ -0,0 +1,107 @@
+# Azure.Analytics.OnlineExperimentation client library for .NET
+
+Azure.Analytics.OnlineExperimentation 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/onlineexperimentation/Azure.Analytics.OnlineExperimentation/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.Analytics.OnlineExperimentation --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/onlineexperimentation/Azure.Analytics.OnlineExperimentation/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
+
+
\ No newline at end of file
diff --git a/sdk/onlineexperimentation/onlineexperimentation/src/Azure.Analytics.OnlineExperimentation.csproj b/sdk/onlineexperimentation/onlineexperimentation/src/Azure.Analytics.OnlineExperimentation.csproj
new file mode 100644
index 000000000000..7a50b5e01e6a
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Azure.Analytics.OnlineExperimentation.csproj
@@ -0,0 +1,19 @@
+
+
+ This is the Azure.Analytics.OnlineExperimentation client library for developing .NET applications with rich experience.
+ Azure SDK Code Generation Azure.Analytics.OnlineExperimentation for Azure Data Plane
+ 1.0.0-beta.1
+ Azure.Analytics.OnlineExperimentation
+ $(RequiredTargetFrameworks)
+ true
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sdk/onlineexperimentation/onlineexperimentation/src/Generated/AggregatedValue.Serialization.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/AggregatedValue.Serialization.cs
new file mode 100644
index 000000000000..3586415a7679
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/AggregatedValue.Serialization.cs
@@ -0,0 +1,161 @@
+// 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.Analytics.OnlineExperimentation
+{
+ public partial class AggregatedValue : 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(AggregatedValue)} does not support writing '{format}' format.");
+ }
+
+ writer.WritePropertyName("eventName"u8);
+ writer.WriteStringValue(EventName);
+ if (Optional.IsDefined(Filter))
+ {
+ writer.WritePropertyName("filter"u8);
+ writer.WriteStringValue(Filter);
+ }
+ writer.WritePropertyName("eventProperty"u8);
+ writer.WriteStringValue(EventProperty);
+ 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
+ }
+ }
+ }
+
+ AggregatedValue 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(AggregatedValue)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeAggregatedValue(document.RootElement, options);
+ }
+
+ internal static AggregatedValue DeserializeAggregatedValue(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ string eventName = default;
+ string filter = default;
+ string eventProperty = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("eventName"u8))
+ {
+ eventName = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("filter"u8))
+ {
+ filter = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("eventProperty"u8))
+ {
+ eventProperty = property.Value.GetString();
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new AggregatedValue(eventName, filter, eventProperty, 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(AggregatedValue)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ AggregatedValue 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 DeserializeAggregatedValue(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(AggregatedValue)} 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 AggregatedValue FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAggregatedValue(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/onlineexperimentation/onlineexperimentation/src/Generated/AggregatedValue.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/AggregatedValue.cs
new file mode 100644
index 000000000000..d1429326a68d
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/AggregatedValue.cs
@@ -0,0 +1,86 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+
+namespace Azure.Analytics.OnlineExperimentation
+{
+ /// An event property value aggregated by a metric.
+ public partial class AggregatedValue
+ {
+ ///
+ /// 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 event.
+ /// The key of the event property to aggregate.
+ /// or is null.
+ public AggregatedValue(string eventName, string eventProperty)
+ {
+ Argument.AssertNotNull(eventName, nameof(eventName));
+ Argument.AssertNotNull(eventProperty, nameof(eventProperty));
+
+ EventName = eventName;
+ EventProperty = eventProperty;
+ }
+
+ /// Initializes a new instance of .
+ /// The name of the event.
+ /// [Optional] A condition to filter events.
+ /// The key of the event property to aggregate.
+ /// Keeps track of any properties unknown to the library.
+ internal AggregatedValue(string eventName, string filter, string eventProperty, IDictionary serializedAdditionalRawData)
+ {
+ EventName = eventName;
+ Filter = filter;
+ EventProperty = eventProperty;
+ _serializedAdditionalRawData = serializedAdditionalRawData;
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal AggregatedValue()
+ {
+ }
+
+ /// The name of the event.
+ public string EventName { get; set; }
+ /// [Optional] A condition to filter events.
+ public string Filter { get; set; }
+ /// The key of the event property to aggregate.
+ public string EventProperty { get; set; }
+ }
+}
diff --git a/sdk/onlineexperimentation/onlineexperimentation/src/Generated/AnalyticsOnlineExperimentationClientBuilderExtensions.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/AnalyticsOnlineExperimentationClientBuilderExtensions.cs
new file mode 100644
index 000000000000..21c9affb0bd5
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/AnalyticsOnlineExperimentationClientBuilderExtensions.cs
@@ -0,0 +1,35 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using Azure.Analytics.OnlineExperimentation;
+using Azure.Core.Extensions;
+
+namespace Microsoft.Extensions.Azure
+{
+ /// Extension methods to add to client builder.
+ public static partial class AnalyticsOnlineExperimentationClientBuilderExtensions
+ {
+ /// Registers a instance.
+ /// The builder to register with.
+ /// Endpoint URL for the Online Experimentation workspace.
+ public static IAzureClientBuilder AddOnlineExperimentationClient(this TBuilder builder, Uri endpoint)
+ where TBuilder : IAzureClientFactoryBuilderWithCredential
+ {
+ return builder.RegisterClientFactory((options, cred) => new OnlineExperimentationClient(endpoint, cred, options));
+ }
+
+ /// Registers a instance.
+ /// The builder to register with.
+ /// The configuration values.
+ public static IAzureClientBuilder AddOnlineExperimentationClient(this TBuilder builder, TConfiguration configuration)
+ where TBuilder : IAzureClientFactoryBuilderWithConfiguration
+ {
+ return builder.RegisterClientFactory(configuration);
+ }
+ }
+}
diff --git a/sdk/onlineexperimentation/onlineexperimentation/src/Generated/AnalyticsOnlineExperimentationModelFactory.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/AnalyticsOnlineExperimentationModelFactory.cs
new file mode 100644
index 000000000000..aca37c179548
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/AnalyticsOnlineExperimentationModelFactory.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;
+using System.Linq;
+
+namespace Azure.Analytics.OnlineExperimentation
+{
+ /// Model factory for models.
+ public static partial class AnalyticsOnlineExperimentationModelFactory
+ {
+ /// Initializes a new instance of .
+ /// An ID used to uniquely identify and reference the metric.
+ /// The stage in the metric lifecycle, which determines when the metric is calculated.
+ /// A display name for the metric to use for display rather than the ID.
+ /// A description of the metric.
+ /// The categories of the metric.
+ /// Whether an increase or decrease to the metric value is desired.
+ ///
+ /// The metric definition, which determines how the metric value is calculated from event data.
+ /// 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 .
+ ///
+ /// ETag of the metric.
+ /// The timestamp of resource last modification (UTC).
+ /// A new instance for mocking.
+ public static ExperimentMetric ExperimentMetric(string id = null, LifecycleStage lifecycle = default, string displayName = null, string description = null, IEnumerable categories = null, DesiredDirection desiredDirection = default, ExperimentMetricDefinition definition = null, ETag eTag = default, DateTimeOffset lastModifiedAt = default)
+ {
+ categories ??= new List();
+
+ return new ExperimentMetric(
+ id,
+ lifecycle,
+ displayName,
+ description,
+ categories?.ToList(),
+ desiredDirection,
+ definition,
+ eTag,
+ lastModifiedAt,
+ serializedAdditionalRawData: null);
+ }
+
+ /// Initializes a new instance of .
+ /// The validation result.
+ /// Whether the metric is valid.
+ /// A new instance for mocking.
+ public static ExperimentMetricValidateResult ExperimentMetricValidateResult(IEnumerable diagnostics = null, ValidationResultOption result = default)
+ {
+ diagnostics ??= new List();
+
+ return new ExperimentMetricValidateResult(diagnostics?.ToList(), result, serializedAdditionalRawData: null);
+ }
+
+ /// Initializes a new instance of .
+ /// The error message.
+ /// The error code.
+ /// A new instance for mocking.
+ public static DiagnosticInfo DiagnosticInfo(string message = null, DiagnosticCode code = default)
+ {
+ return new DiagnosticInfo(message, code, serializedAdditionalRawData: null);
+ }
+ }
+}
diff --git a/sdk/onlineexperimentation/onlineexperimentation/src/Generated/AverageDefinition.Serialization.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/AverageDefinition.Serialization.cs
new file mode 100644
index 000000000000..4c0dd265b533
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/AverageDefinition.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.Analytics.OnlineExperimentation
+{
+ public partial class AverageDefinition : 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(AverageDefinition)} does not support writing '{format}' format.");
+ }
+
+ base.JsonModelWriteCore(writer, options);
+ writer.WritePropertyName("value"u8);
+ writer.WriteObjectValue(Value, options);
+ }
+
+ AverageDefinition 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(AverageDefinition)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeAverageDefinition(document.RootElement, options);
+ }
+
+ internal static AverageDefinition DeserializeAverageDefinition(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ AggregatedValue value = default;
+ MetricType type = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("value"u8))
+ {
+ value = AggregatedValue.DeserializeAggregatedValue(property.Value, options);
+ continue;
+ }
+ if (property.NameEquals("type"u8))
+ {
+ type = new MetricType(property.Value.GetString());
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new AverageDefinition(type, serializedAdditionalRawData, value);
+ }
+
+ 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(AverageDefinition)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ AverageDefinition 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 DeserializeAverageDefinition(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(AverageDefinition)} 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 AverageDefinition FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAverageDefinition(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/onlineexperimentation/onlineexperimentation/src/Generated/AverageDefinition.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/AverageDefinition.cs
new file mode 100644
index 000000000000..f1c811950802
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/AverageDefinition.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.Analytics.OnlineExperimentation
+{
+ /// The definition of an Average metric. This metric type measures the average of an event property.
+ public partial class AverageDefinition : ExperimentMetricDefinition
+ {
+ /// Initializes a new instance of .
+ /// The value to aggregate.
+ /// is null.
+ public AverageDefinition(AggregatedValue value)
+ {
+ Argument.AssertNotNull(value, nameof(value));
+
+ Type = MetricType.Average;
+ Value = value;
+ }
+
+ /// Initializes a new instance of .
+ /// Discriminator property for ExperimentMetricDefinition.
+ /// Keeps track of any properties unknown to the library.
+ /// The value to aggregate.
+ internal AverageDefinition(MetricType type, IDictionary serializedAdditionalRawData, AggregatedValue value) : base(type, serializedAdditionalRawData)
+ {
+ Value = value;
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal AverageDefinition()
+ {
+ }
+
+ /// The value to aggregate.
+ public AggregatedValue Value { get; set; }
+ }
+}
diff --git a/sdk/onlineexperimentation/onlineexperimentation/src/Generated/DesiredDirection.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/DesiredDirection.cs
new file mode 100644
index 000000000000..8e45f8bdcb33
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/DesiredDirection.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.Analytics.OnlineExperimentation
+{
+ /// Desired direction of the metric.
+ public readonly partial struct DesiredDirection : IEquatable
+ {
+ private readonly string _value;
+
+ /// Initializes a new instance of .
+ /// is null.
+ public DesiredDirection(string value)
+ {
+ _value = value ?? throw new ArgumentNullException(nameof(value));
+ }
+
+ private const string IncreaseValue = "Increase";
+ private const string DecreaseValue = "Decrease";
+ private const string NeutralValue = "Neutral";
+
+ /// An increase to the metric value is desired. E.g., Success rate, Total revenue.
+ public static DesiredDirection Increase { get; } = new DesiredDirection(IncreaseValue);
+ /// A decrease to the metric value is desired. E.g., Error rate, Latency.
+ public static DesiredDirection Decrease { get; } = new DesiredDirection(DecreaseValue);
+ /// Neither an increase nor a decrease to the metric value is desired, or the desired direction depends on other factors. E.g., Number of video play attempts, Number of user feedbacks.
+ public static DesiredDirection Neutral { get; } = new DesiredDirection(NeutralValue);
+ /// Determines if two values are the same.
+ public static bool operator ==(DesiredDirection left, DesiredDirection right) => left.Equals(right);
+ /// Determines if two values are not the same.
+ public static bool operator !=(DesiredDirection left, DesiredDirection right) => !left.Equals(right);
+ /// Converts a to a .
+ public static implicit operator DesiredDirection(string value) => new DesiredDirection(value);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool Equals(object obj) => obj is DesiredDirection other && Equals(other);
+ ///
+ public bool Equals(DesiredDirection 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/onlineexperimentation/onlineexperimentation/src/Generated/DiagnosticCode.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/DiagnosticCode.cs
new file mode 100644
index 000000000000..8292e54ab144
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/DiagnosticCode.cs
@@ -0,0 +1,62 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ComponentModel;
+
+namespace Azure.Analytics.OnlineExperimentation
+{
+ /// The diagnostic error codes.
+ public readonly partial struct DiagnosticCode : IEquatable
+ {
+ private readonly string _value;
+
+ /// Initializes a new instance of .
+ /// is null.
+ public DiagnosticCode(string value)
+ {
+ _value = value ?? throw new ArgumentNullException(nameof(value));
+ }
+
+ private const string FailedSchemaValidationValue = "FailedSchemaValidation";
+ private const string InvalidEventConditionValue = "InvalidEventCondition";
+ private const string UnsupportedEventConditionValue = "UnsupportedEventCondition";
+ private const string InvalidExperimentMetricDefinitionValue = "InvalidExperimentMetricDefinition";
+
+ /// The metric definition is not according to Json Schema.
+ public static DiagnosticCode FailedSchemaValidation { get; } = new DiagnosticCode(FailedSchemaValidationValue);
+ /// The KQL filter condition is invalid.
+ public static DiagnosticCode InvalidEventCondition { get; } = new DiagnosticCode(InvalidEventConditionValue);
+ /// The KQL filter condition is valid but not currently supported.
+ public static DiagnosticCode UnsupportedEventCondition { get; } = new DiagnosticCode(UnsupportedEventConditionValue);
+ ///
+ /// The metric definition provided is invalid.
+ /// for example, if the metric is defined to calculate the average of the Revenue property,
+ /// but also includes a filter such as Revenue == 'hello', this creates a type mismatch.
+ /// The system infers conflicting data types—numeric and string—resulting in a validation failure.
+ ///
+ public static DiagnosticCode InvalidExperimentMetricDefinition { get; } = new DiagnosticCode(InvalidExperimentMetricDefinitionValue);
+ /// Determines if two values are the same.
+ public static bool operator ==(DiagnosticCode left, DiagnosticCode right) => left.Equals(right);
+ /// Determines if two values are not the same.
+ public static bool operator !=(DiagnosticCode left, DiagnosticCode right) => !left.Equals(right);
+ /// Converts a to a .
+ public static implicit operator DiagnosticCode(string value) => new DiagnosticCode(value);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool Equals(object obj) => obj is DiagnosticCode other && Equals(other);
+ ///
+ public bool Equals(DiagnosticCode 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/onlineexperimentation/onlineexperimentation/src/Generated/DiagnosticInfo.Serialization.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/DiagnosticInfo.Serialization.cs
new file mode 100644
index 000000000000..364be3c9bfbf
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/DiagnosticInfo.Serialization.cs
@@ -0,0 +1,156 @@
+// 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.Analytics.OnlineExperimentation
+{
+ public partial class DiagnosticInfo : 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(DiagnosticInfo)} does not support writing '{format}' format.");
+ }
+
+ if (options.Format != "W")
+ {
+ writer.WritePropertyName("message"u8);
+ writer.WriteStringValue(Message);
+ }
+ if (options.Format != "W")
+ {
+ writer.WritePropertyName("code"u8);
+ writer.WriteStringValue(Code.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
+ }
+ }
+ }
+
+ DiagnosticInfo 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(DiagnosticInfo)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeDiagnosticInfo(document.RootElement, options);
+ }
+
+ internal static DiagnosticInfo DeserializeDiagnosticInfo(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ string message = default;
+ DiagnosticCode code = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("message"u8))
+ {
+ message = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("code"u8))
+ {
+ code = new DiagnosticCode(property.Value.GetString());
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new DiagnosticInfo(message, code, 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(DiagnosticInfo)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ DiagnosticInfo 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 DeserializeDiagnosticInfo(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(DiagnosticInfo)} 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 DiagnosticInfo FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeDiagnosticInfo(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/onlineexperimentation/onlineexperimentation/src/Generated/DiagnosticInfo.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/DiagnosticInfo.cs
new file mode 100644
index 000000000000..d52d96dc95da
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/DiagnosticInfo.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.Analytics.OnlineExperimentation
+{
+ /// The diagnostic information.
+ public partial class DiagnosticInfo
+ {
+ ///
+ /// 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 DiagnosticInfo()
+ {
+ }
+
+ /// Initializes a new instance of .
+ /// The error message.
+ /// The error code.
+ /// Keeps track of any properties unknown to the library.
+ internal DiagnosticInfo(string message, DiagnosticCode code, IDictionary serializedAdditionalRawData)
+ {
+ Message = message;
+ Code = code;
+ _serializedAdditionalRawData = serializedAdditionalRawData;
+ }
+
+ /// The error message.
+ public string Message { get; }
+ /// The error code.
+ public DiagnosticCode Code { get; }
+ }
+}
diff --git a/sdk/onlineexperimentation/onlineexperimentation/src/Generated/Docs/ExperimentMetrics.xml b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/Docs/ExperimentMetrics.xml
new file mode 100644
index 000000000000..e9d23da76ada
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/Docs/ExperimentMetrics.xml
@@ -0,0 +1,855 @@
+
+
+
+
+
+This sample shows how to call GetExperimentMetricAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+Response response = await client.GetExperimentMetricAsync("events_purchase_creditcard");
+]]>
+
+
+
+This sample shows how to call GetExperimentMetric.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+Response response = client.GetExperimentMetric("events_purchase_creditcard");
+]]>
+
+
+
+This sample shows how to call GetExperimentMetricAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+Response response = await client.GetExperimentMetricAsync("events_purchase_creditcard", null, null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("id").ToString());
+Console.WriteLine(result.GetProperty("lifecycle").ToString());
+Console.WriteLine(result.GetProperty("displayName").ToString());
+Console.WriteLine(result.GetProperty("description").ToString());
+Console.WriteLine(result.GetProperty("categories")[0].ToString());
+Console.WriteLine(result.GetProperty("desiredDirection").ToString());
+Console.WriteLine(result.GetProperty("definition").GetProperty("type").ToString());
+Console.WriteLine(result.GetProperty("eTag").ToString());
+Console.WriteLine(result.GetProperty("lastModifiedAt").ToString());
+]]>
+
+
+
+This sample shows how to call GetExperimentMetric and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+Response response = client.GetExperimentMetric("events_purchase_creditcard", null, null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("id").ToString());
+Console.WriteLine(result.GetProperty("lifecycle").ToString());
+Console.WriteLine(result.GetProperty("displayName").ToString());
+Console.WriteLine(result.GetProperty("description").ToString());
+Console.WriteLine(result.GetProperty("categories")[0].ToString());
+Console.WriteLine(result.GetProperty("desiredDirection").ToString());
+Console.WriteLine(result.GetProperty("definition").GetProperty("type").ToString());
+Console.WriteLine(result.GetProperty("eTag").ToString());
+Console.WriteLine(result.GetProperty("lastModifiedAt").ToString());
+]]>
+
+
+
+This sample shows how to call CreateOrUpdateAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+using RequestContent content = RequestContent.Create(new
+{
+ displayName = "Average revenue per purchase [USD]",
+ description = "The average revenue per purchase transaction in USD. Refund transactions are excluded from this metric. The total revenue might increase while this metric decreases if the number of purchases increases.",
+ lifecycle = "Active",
+ categories = new object[]
+ {
+ "Monetization"
+ },
+ desiredDirection = "Increase",
+ definition = new
+ {
+ type = "Average",
+ value = new
+ {
+ eventName = "Transaction",
+ eventProperty = "Revenue",
+ filter = "Revenue > 0",
+ },
+ },
+});
+Response response = await client.CreateOrUpdateAsync("avg_purchase_revenue", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("id").ToString());
+Console.WriteLine(result.GetProperty("lifecycle").ToString());
+Console.WriteLine(result.GetProperty("displayName").ToString());
+Console.WriteLine(result.GetProperty("description").ToString());
+Console.WriteLine(result.GetProperty("categories")[0].ToString());
+Console.WriteLine(result.GetProperty("desiredDirection").ToString());
+Console.WriteLine(result.GetProperty("definition").GetProperty("type").ToString());
+Console.WriteLine(result.GetProperty("eTag").ToString());
+Console.WriteLine(result.GetProperty("lastModifiedAt").ToString());
+]]>
+This sample shows how to call CreateOrUpdateAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+using RequestContent content = RequestContent.Create(new
+{
+ displayName = "Number of purchases (credit card)",
+ description = "The number of purchase transactions made with credit card. Refund transactions are excluded from this metric.",
+ lifecycle = "Active",
+ categories = new object[]
+ {
+ "Monetization"
+ },
+ desiredDirection = "Increase",
+ definition = new Dictionary
+ {
+ ["type"] = "EventCount",
+ ["event"] = new
+ {
+ eventName = "Transaction",
+ filter = "Revenue > 0 and ['payment.method'] == 'credit_card'",
+ }
+ },
+});
+Response response = await client.CreateOrUpdateAsync("events_purchase_creditcard", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("id").ToString());
+Console.WriteLine(result.GetProperty("lifecycle").ToString());
+Console.WriteLine(result.GetProperty("displayName").ToString());
+Console.WriteLine(result.GetProperty("description").ToString());
+Console.WriteLine(result.GetProperty("categories")[0].ToString());
+Console.WriteLine(result.GetProperty("desiredDirection").ToString());
+Console.WriteLine(result.GetProperty("definition").GetProperty("type").ToString());
+Console.WriteLine(result.GetProperty("eTag").ToString());
+Console.WriteLine(result.GetProperty("lastModifiedAt").ToString());
+]]>
+This sample shows how to call CreateOrUpdateAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+using RequestContent content = RequestContent.Create(new
+{
+ displayName = "Refund rate",
+ description = "The percentage of transactions that are refunds. This metric is calculated as the number of refund transactions divided by the total number of transactions.",
+ lifecycle = "Active",
+ categories = new object[]
+ {
+ "Monetization"
+ },
+ desiredDirection = "Neutral",
+ definition = new Dictionary
+ {
+ ["type"] = "EventRate",
+ ["event"] = new
+ {
+ eventName = "Transaction",
+ },
+ ["rateCondition"] = "Revenue < 0"
+ },
+});
+Response response = await client.CreateOrUpdateAsync("rate_refund", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("id").ToString());
+Console.WriteLine(result.GetProperty("lifecycle").ToString());
+Console.WriteLine(result.GetProperty("displayName").ToString());
+Console.WriteLine(result.GetProperty("description").ToString());
+Console.WriteLine(result.GetProperty("categories")[0].ToString());
+Console.WriteLine(result.GetProperty("desiredDirection").ToString());
+Console.WriteLine(result.GetProperty("definition").GetProperty("type").ToString());
+Console.WriteLine(result.GetProperty("eTag").ToString());
+Console.WriteLine(result.GetProperty("lastModifiedAt").ToString());
+]]>
+This sample shows how to call CreateOrUpdateAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+using RequestContent content = RequestContent.Create(new
+{
+ displayName = "95th percentile of page load time [ms]",
+ description = "The 95th percentile of the page load time for all pages. Measured in milliseconds. Review page-specific metric results to identify pages that need optimization.",
+ lifecycle = "Active",
+ categories = new object[]
+ {
+ "Performance",
+ "Important"
+ },
+ desiredDirection = "Decrease",
+ definition = new
+ {
+ type = "Percentile",
+ value = new
+ {
+ eventName = "PageLoad",
+ eventProperty = "LoadTime_ms",
+ },
+ percentile = 95,
+ },
+});
+Response response = await client.CreateOrUpdateAsync("p95_page_load_time", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("id").ToString());
+Console.WriteLine(result.GetProperty("lifecycle").ToString());
+Console.WriteLine(result.GetProperty("displayName").ToString());
+Console.WriteLine(result.GetProperty("description").ToString());
+Console.WriteLine(result.GetProperty("categories")[0].ToString());
+Console.WriteLine(result.GetProperty("desiredDirection").ToString());
+Console.WriteLine(result.GetProperty("definition").GetProperty("type").ToString());
+Console.WriteLine(result.GetProperty("eTag").ToString());
+Console.WriteLine(result.GetProperty("lastModifiedAt").ToString());
+]]>
+This sample shows how to call CreateOrUpdateAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+using RequestContent content = RequestContent.Create(new
+{
+ displayName = "Total revenue [USD]",
+ description = "The total revenue in USD. Refund transactions contribute negatively to this metric.",
+ lifecycle = "Active",
+ categories = new object[]
+ {
+ "Monetization",
+ "Important"
+ },
+ desiredDirection = "Increase",
+ definition = new
+ {
+ type = "Sum",
+ value = new
+ {
+ eventName = "Transaction",
+ eventProperty = "Revenue",
+ },
+ },
+});
+Response response = await client.CreateOrUpdateAsync("sum_revenue", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("id").ToString());
+Console.WriteLine(result.GetProperty("lifecycle").ToString());
+Console.WriteLine(result.GetProperty("displayName").ToString());
+Console.WriteLine(result.GetProperty("description").ToString());
+Console.WriteLine(result.GetProperty("categories")[0].ToString());
+Console.WriteLine(result.GetProperty("desiredDirection").ToString());
+Console.WriteLine(result.GetProperty("definition").GetProperty("type").ToString());
+Console.WriteLine(result.GetProperty("eTag").ToString());
+Console.WriteLine(result.GetProperty("lastModifiedAt").ToString());
+]]>
+This sample shows how to call CreateOrUpdateAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+using RequestContent content = RequestContent.Create(new
+{
+ displayName = "Users with purchase",
+ description = "The number of users who have made at least one purchase transaction. Refund transactions are excluded from this metric. As the analysis period grows, this metric begins to saturate as users making multiple purchases no longer contribute.",
+ lifecycle = "Active",
+ categories = new object[]
+ {
+ "Monetization"
+ },
+ desiredDirection = "Increase",
+ definition = new Dictionary
+ {
+ ["type"] = "UserCount",
+ ["event"] = new
+ {
+ eventName = "Transaction",
+ filter = "Revenue > 0",
+ }
+ },
+});
+Response response = await client.CreateOrUpdateAsync("users_purchase", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("id").ToString());
+Console.WriteLine(result.GetProperty("lifecycle").ToString());
+Console.WriteLine(result.GetProperty("displayName").ToString());
+Console.WriteLine(result.GetProperty("description").ToString());
+Console.WriteLine(result.GetProperty("categories")[0].ToString());
+Console.WriteLine(result.GetProperty("desiredDirection").ToString());
+Console.WriteLine(result.GetProperty("definition").GetProperty("type").ToString());
+Console.WriteLine(result.GetProperty("eTag").ToString());
+Console.WriteLine(result.GetProperty("lastModifiedAt").ToString());
+]]>
+This sample shows how to call CreateOrUpdateAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+using RequestContent content = RequestContent.Create(new
+{
+ displayName = "Subscription ad conversion rate",
+ description = "The percentage of users who saw an advertisement for a subscription promotion and then later successfully subscribed. This metric is calculated as the number of users who successfully subscribed after seeing the advert divided by the total number of users who saw the advert. Users who saw multiple adverts or subscribed multiple times are counted only once. Users who saw the advert before the analysis period starts are excluded from this metric.",
+ lifecycle = "Active",
+ categories = new object[]
+ {
+ "Monetization"
+ },
+ desiredDirection = "Increase",
+ definition = new
+ {
+ type = "UserRate",
+ startEvent = new
+ {
+ eventName = "AdView",
+ filter = "Source == 'subscription_promo'",
+ },
+ endEvent = new
+ {
+ eventName = "Subscribe",
+ filter = "Status == 'Success'",
+ },
+ },
+});
+Response response = await client.CreateOrUpdateAsync("rate_subscription_ad", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("id").ToString());
+Console.WriteLine(result.GetProperty("lifecycle").ToString());
+Console.WriteLine(result.GetProperty("displayName").ToString());
+Console.WriteLine(result.GetProperty("description").ToString());
+Console.WriteLine(result.GetProperty("categories")[0].ToString());
+Console.WriteLine(result.GetProperty("desiredDirection").ToString());
+Console.WriteLine(result.GetProperty("definition").GetProperty("type").ToString());
+Console.WriteLine(result.GetProperty("eTag").ToString());
+Console.WriteLine(result.GetProperty("lastModifiedAt").ToString());
+]]>
+
+
+
+This sample shows how to call CreateOrUpdate and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+using RequestContent content = RequestContent.Create(new
+{
+ displayName = "Average revenue per purchase [USD]",
+ description = "The average revenue per purchase transaction in USD. Refund transactions are excluded from this metric. The total revenue might increase while this metric decreases if the number of purchases increases.",
+ lifecycle = "Active",
+ categories = new object[]
+ {
+ "Monetization"
+ },
+ desiredDirection = "Increase",
+ definition = new
+ {
+ type = "Average",
+ value = new
+ {
+ eventName = "Transaction",
+ eventProperty = "Revenue",
+ filter = "Revenue > 0",
+ },
+ },
+});
+Response response = client.CreateOrUpdate("avg_purchase_revenue", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("id").ToString());
+Console.WriteLine(result.GetProperty("lifecycle").ToString());
+Console.WriteLine(result.GetProperty("displayName").ToString());
+Console.WriteLine(result.GetProperty("description").ToString());
+Console.WriteLine(result.GetProperty("categories")[0].ToString());
+Console.WriteLine(result.GetProperty("desiredDirection").ToString());
+Console.WriteLine(result.GetProperty("definition").GetProperty("type").ToString());
+Console.WriteLine(result.GetProperty("eTag").ToString());
+Console.WriteLine(result.GetProperty("lastModifiedAt").ToString());
+]]>
+This sample shows how to call CreateOrUpdate and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+using RequestContent content = RequestContent.Create(new
+{
+ displayName = "Number of purchases (credit card)",
+ description = "The number of purchase transactions made with credit card. Refund transactions are excluded from this metric.",
+ lifecycle = "Active",
+ categories = new object[]
+ {
+ "Monetization"
+ },
+ desiredDirection = "Increase",
+ definition = new Dictionary
+ {
+ ["type"] = "EventCount",
+ ["event"] = new
+ {
+ eventName = "Transaction",
+ filter = "Revenue > 0 and ['payment.method'] == 'credit_card'",
+ }
+ },
+});
+Response response = client.CreateOrUpdate("events_purchase_creditcard", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("id").ToString());
+Console.WriteLine(result.GetProperty("lifecycle").ToString());
+Console.WriteLine(result.GetProperty("displayName").ToString());
+Console.WriteLine(result.GetProperty("description").ToString());
+Console.WriteLine(result.GetProperty("categories")[0].ToString());
+Console.WriteLine(result.GetProperty("desiredDirection").ToString());
+Console.WriteLine(result.GetProperty("definition").GetProperty("type").ToString());
+Console.WriteLine(result.GetProperty("eTag").ToString());
+Console.WriteLine(result.GetProperty("lastModifiedAt").ToString());
+]]>
+This sample shows how to call CreateOrUpdate and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+using RequestContent content = RequestContent.Create(new
+{
+ displayName = "Refund rate",
+ description = "The percentage of transactions that are refunds. This metric is calculated as the number of refund transactions divided by the total number of transactions.",
+ lifecycle = "Active",
+ categories = new object[]
+ {
+ "Monetization"
+ },
+ desiredDirection = "Neutral",
+ definition = new Dictionary
+ {
+ ["type"] = "EventRate",
+ ["event"] = new
+ {
+ eventName = "Transaction",
+ },
+ ["rateCondition"] = "Revenue < 0"
+ },
+});
+Response response = client.CreateOrUpdate("rate_refund", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("id").ToString());
+Console.WriteLine(result.GetProperty("lifecycle").ToString());
+Console.WriteLine(result.GetProperty("displayName").ToString());
+Console.WriteLine(result.GetProperty("description").ToString());
+Console.WriteLine(result.GetProperty("categories")[0].ToString());
+Console.WriteLine(result.GetProperty("desiredDirection").ToString());
+Console.WriteLine(result.GetProperty("definition").GetProperty("type").ToString());
+Console.WriteLine(result.GetProperty("eTag").ToString());
+Console.WriteLine(result.GetProperty("lastModifiedAt").ToString());
+]]>
+This sample shows how to call CreateOrUpdate and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+using RequestContent content = RequestContent.Create(new
+{
+ displayName = "95th percentile of page load time [ms]",
+ description = "The 95th percentile of the page load time for all pages. Measured in milliseconds. Review page-specific metric results to identify pages that need optimization.",
+ lifecycle = "Active",
+ categories = new object[]
+ {
+ "Performance",
+ "Important"
+ },
+ desiredDirection = "Decrease",
+ definition = new
+ {
+ type = "Percentile",
+ value = new
+ {
+ eventName = "PageLoad",
+ eventProperty = "LoadTime_ms",
+ },
+ percentile = 95,
+ },
+});
+Response response = client.CreateOrUpdate("p95_page_load_time", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("id").ToString());
+Console.WriteLine(result.GetProperty("lifecycle").ToString());
+Console.WriteLine(result.GetProperty("displayName").ToString());
+Console.WriteLine(result.GetProperty("description").ToString());
+Console.WriteLine(result.GetProperty("categories")[0].ToString());
+Console.WriteLine(result.GetProperty("desiredDirection").ToString());
+Console.WriteLine(result.GetProperty("definition").GetProperty("type").ToString());
+Console.WriteLine(result.GetProperty("eTag").ToString());
+Console.WriteLine(result.GetProperty("lastModifiedAt").ToString());
+]]>
+This sample shows how to call CreateOrUpdate and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+using RequestContent content = RequestContent.Create(new
+{
+ displayName = "Total revenue [USD]",
+ description = "The total revenue in USD. Refund transactions contribute negatively to this metric.",
+ lifecycle = "Active",
+ categories = new object[]
+ {
+ "Monetization",
+ "Important"
+ },
+ desiredDirection = "Increase",
+ definition = new
+ {
+ type = "Sum",
+ value = new
+ {
+ eventName = "Transaction",
+ eventProperty = "Revenue",
+ },
+ },
+});
+Response response = client.CreateOrUpdate("sum_revenue", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("id").ToString());
+Console.WriteLine(result.GetProperty("lifecycle").ToString());
+Console.WriteLine(result.GetProperty("displayName").ToString());
+Console.WriteLine(result.GetProperty("description").ToString());
+Console.WriteLine(result.GetProperty("categories")[0].ToString());
+Console.WriteLine(result.GetProperty("desiredDirection").ToString());
+Console.WriteLine(result.GetProperty("definition").GetProperty("type").ToString());
+Console.WriteLine(result.GetProperty("eTag").ToString());
+Console.WriteLine(result.GetProperty("lastModifiedAt").ToString());
+]]>
+This sample shows how to call CreateOrUpdate and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+using RequestContent content = RequestContent.Create(new
+{
+ displayName = "Users with purchase",
+ description = "The number of users who have made at least one purchase transaction. Refund transactions are excluded from this metric. As the analysis period grows, this metric begins to saturate as users making multiple purchases no longer contribute.",
+ lifecycle = "Active",
+ categories = new object[]
+ {
+ "Monetization"
+ },
+ desiredDirection = "Increase",
+ definition = new Dictionary
+ {
+ ["type"] = "UserCount",
+ ["event"] = new
+ {
+ eventName = "Transaction",
+ filter = "Revenue > 0",
+ }
+ },
+});
+Response response = client.CreateOrUpdate("users_purchase", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("id").ToString());
+Console.WriteLine(result.GetProperty("lifecycle").ToString());
+Console.WriteLine(result.GetProperty("displayName").ToString());
+Console.WriteLine(result.GetProperty("description").ToString());
+Console.WriteLine(result.GetProperty("categories")[0].ToString());
+Console.WriteLine(result.GetProperty("desiredDirection").ToString());
+Console.WriteLine(result.GetProperty("definition").GetProperty("type").ToString());
+Console.WriteLine(result.GetProperty("eTag").ToString());
+Console.WriteLine(result.GetProperty("lastModifiedAt").ToString());
+]]>
+This sample shows how to call CreateOrUpdate and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+using RequestContent content = RequestContent.Create(new
+{
+ displayName = "Subscription ad conversion rate",
+ description = "The percentage of users who saw an advertisement for a subscription promotion and then later successfully subscribed. This metric is calculated as the number of users who successfully subscribed after seeing the advert divided by the total number of users who saw the advert. Users who saw multiple adverts or subscribed multiple times are counted only once. Users who saw the advert before the analysis period starts are excluded from this metric.",
+ lifecycle = "Active",
+ categories = new object[]
+ {
+ "Monetization"
+ },
+ desiredDirection = "Increase",
+ definition = new
+ {
+ type = "UserRate",
+ startEvent = new
+ {
+ eventName = "AdView",
+ filter = "Source == 'subscription_promo'",
+ },
+ endEvent = new
+ {
+ eventName = "Subscribe",
+ filter = "Status == 'Success'",
+ },
+ },
+});
+Response response = client.CreateOrUpdate("rate_subscription_ad", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("id").ToString());
+Console.WriteLine(result.GetProperty("lifecycle").ToString());
+Console.WriteLine(result.GetProperty("displayName").ToString());
+Console.WriteLine(result.GetProperty("description").ToString());
+Console.WriteLine(result.GetProperty("categories")[0].ToString());
+Console.WriteLine(result.GetProperty("desiredDirection").ToString());
+Console.WriteLine(result.GetProperty("definition").GetProperty("type").ToString());
+Console.WriteLine(result.GetProperty("eTag").ToString());
+Console.WriteLine(result.GetProperty("lastModifiedAt").ToString());
+]]>
+
+
+
+This sample shows how to call ValidateAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+ExperimentMetric body = new ExperimentMetric(
+LifecycleStage.Active,
+"Average revenue per purchase [USD]",
+"The average revenue per purchase transaction in USD. Refund transactions are excluded from this metric. The total revenue might increase while this metric decreases if the number of purchases increases.",
+new string[] { "Monetization" },
+DesiredDirection.Increase,
+new AverageDefinition(new AggregatedValue("Transaction", "Revenue")
+{
+ Filter = "Revenue >",
+}));
+Response response = await client.ValidateAsync("events_purchase_creditcard", body);
+]]>
+
+
+
+This sample shows how to call Validate.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+ExperimentMetric body = new ExperimentMetric(
+LifecycleStage.Active,
+"Average revenue per purchase [USD]",
+"The average revenue per purchase transaction in USD. Refund transactions are excluded from this metric. The total revenue might increase while this metric decreases if the number of purchases increases.",
+new string[] { "Monetization" },
+DesiredDirection.Increase,
+new AverageDefinition(new AggregatedValue("Transaction", "Revenue")
+{
+ Filter = "Revenue >",
+}));
+Response response = client.Validate("events_purchase_creditcard", body);
+]]>
+
+
+
+This sample shows how to call ValidateAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+using RequestContent content = RequestContent.Create(new
+{
+ displayName = "Average revenue per purchase [USD]",
+ description = "The average revenue per purchase transaction in USD. Refund transactions are excluded from this metric. The total revenue might increase while this metric decreases if the number of purchases increases.",
+ lifecycle = "Active",
+ categories = new object[]
+ {
+ "Monetization"
+ },
+ desiredDirection = "Increase",
+ definition = new
+ {
+ type = "Average",
+ value = new
+ {
+ eventName = "Transaction",
+ eventProperty = "Revenue",
+ filter = "Revenue >",
+ },
+ },
+});
+Response response = await client.ValidateAsync("events_purchase_creditcard", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("diagnostics")[0].GetProperty("message").ToString());
+Console.WriteLine(result.GetProperty("diagnostics")[0].GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("result").ToString());
+]]>
+
+
+
+This sample shows how to call Validate and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+using RequestContent content = RequestContent.Create(new
+{
+ displayName = "Average revenue per purchase [USD]",
+ description = "The average revenue per purchase transaction in USD. Refund transactions are excluded from this metric. The total revenue might increase while this metric decreases if the number of purchases increases.",
+ lifecycle = "Active",
+ categories = new object[]
+ {
+ "Monetization"
+ },
+ desiredDirection = "Increase",
+ definition = new
+ {
+ type = "Average",
+ value = new
+ {
+ eventName = "Transaction",
+ eventProperty = "Revenue",
+ filter = "Revenue >",
+ },
+ },
+});
+Response response = client.Validate("events_purchase_creditcard", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("diagnostics")[0].GetProperty("message").ToString());
+Console.WriteLine(result.GetProperty("diagnostics")[0].GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("result").ToString());
+]]>
+
+
+
+This sample shows how to call DeleteAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+Response response = await client.DeleteAsync("avg_purchase_revenue");
+
+Console.WriteLine(response.Status);
+]]>
+
+
+
+This sample shows how to call Delete.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+Response response = client.Delete("avg_purchase_revenue");
+
+Console.WriteLine(response.Status);
+]]>
+
+
+
+This sample shows how to call GetExperimentMetricsAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+await foreach (ExperimentMetric item in client.GetExperimentMetricsAsync())
+{
+}
+]]>
+
+
+
+This sample shows how to call GetExperimentMetrics.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+foreach (ExperimentMetric item in client.GetExperimentMetrics())
+{
+}
+]]>
+
+
+
+This sample shows how to call GetExperimentMetricsAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+await foreach (BinaryData item in client.GetExperimentMetricsAsync(null))
+{
+ JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement;
+ Console.WriteLine(result.GetProperty("id").ToString());
+ Console.WriteLine(result.GetProperty("lifecycle").ToString());
+ Console.WriteLine(result.GetProperty("displayName").ToString());
+ Console.WriteLine(result.GetProperty("description").ToString());
+ Console.WriteLine(result.GetProperty("categories")[0].ToString());
+ Console.WriteLine(result.GetProperty("desiredDirection").ToString());
+ Console.WriteLine(result.GetProperty("definition").GetProperty("type").ToString());
+ Console.WriteLine(result.GetProperty("eTag").ToString());
+ Console.WriteLine(result.GetProperty("lastModifiedAt").ToString());
+}
+]]>
+
+
+
+This sample shows how to call GetExperimentMetrics and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+ExperimentMetrics client = new OnlineExperimentationClient(endpoint, credential).GetExperimentMetricsClient(apiVersion: "2025-05-31-preview");
+
+foreach (BinaryData item in client.GetExperimentMetrics(null))
+{
+ JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement;
+ Console.WriteLine(result.GetProperty("id").ToString());
+ Console.WriteLine(result.GetProperty("lifecycle").ToString());
+ Console.WriteLine(result.GetProperty("displayName").ToString());
+ Console.WriteLine(result.GetProperty("description").ToString());
+ Console.WriteLine(result.GetProperty("categories")[0].ToString());
+ Console.WriteLine(result.GetProperty("desiredDirection").ToString());
+ Console.WriteLine(result.GetProperty("definition").GetProperty("type").ToString());
+ Console.WriteLine(result.GetProperty("eTag").ToString());
+ Console.WriteLine(result.GetProperty("lastModifiedAt").ToString());
+}
+]]>
+
+
+
\ No newline at end of file
diff --git a/sdk/onlineexperimentation/onlineexperimentation/src/Generated/EventCountDefinition.Serialization.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/EventCountDefinition.Serialization.cs
new file mode 100644
index 000000000000..fe4b4ec248da
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/EventCountDefinition.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.Analytics.OnlineExperimentation
+{
+ public partial class EventCountDefinition : 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(EventCountDefinition)} does not support writing '{format}' format.");
+ }
+
+ base.JsonModelWriteCore(writer, options);
+ writer.WritePropertyName("event"u8);
+ writer.WriteObjectValue(Event, options);
+ }
+
+ EventCountDefinition 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(EventCountDefinition)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeEventCountDefinition(document.RootElement, options);
+ }
+
+ internal static EventCountDefinition DeserializeEventCountDefinition(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ ObservedEvent @event = default;
+ MetricType type = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("event"u8))
+ {
+ @event = ObservedEvent.DeserializeObservedEvent(property.Value, options);
+ continue;
+ }
+ if (property.NameEquals("type"u8))
+ {
+ type = new MetricType(property.Value.GetString());
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new EventCountDefinition(type, serializedAdditionalRawData, @event);
+ }
+
+ 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(EventCountDefinition)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ EventCountDefinition 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 DeserializeEventCountDefinition(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(EventCountDefinition)} 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 EventCountDefinition FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeEventCountDefinition(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/onlineexperimentation/onlineexperimentation/src/Generated/EventCountDefinition.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/EventCountDefinition.cs
new file mode 100644
index 000000000000..db41a88064b5
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/EventCountDefinition.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.Analytics.OnlineExperimentation
+{
+ /// The definition of an EventCount metric. This metric type counts the observations of an event. Experiment analysis accounts for unequal traffic allocation.
+ public partial class EventCountDefinition : ExperimentMetricDefinition
+ {
+ /// Initializes a new instance of .
+ /// Event to observe.
+ /// is null.
+ public EventCountDefinition(ObservedEvent @event)
+ {
+ Argument.AssertNotNull(@event, nameof(@event));
+
+ Type = MetricType.EventCount;
+ Event = @event;
+ }
+
+ /// Initializes a new instance of .
+ /// Discriminator property for ExperimentMetricDefinition.
+ /// Keeps track of any properties unknown to the library.
+ /// Event to observe.
+ internal EventCountDefinition(MetricType type, IDictionary serializedAdditionalRawData, ObservedEvent @event) : base(type, serializedAdditionalRawData)
+ {
+ Event = @event;
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal EventCountDefinition()
+ {
+ }
+
+ /// Event to observe.
+ public ObservedEvent Event { get; set; }
+ }
+}
diff --git a/sdk/onlineexperimentation/onlineexperimentation/src/Generated/EventRateDefinition.Serialization.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/EventRateDefinition.Serialization.cs
new file mode 100644
index 000000000000..98199fbf7381
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/EventRateDefinition.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.Analytics.OnlineExperimentation
+{
+ public partial class EventRateDefinition : 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(EventRateDefinition)} does not support writing '{format}' format.");
+ }
+
+ base.JsonModelWriteCore(writer, options);
+ writer.WritePropertyName("event"u8);
+ writer.WriteObjectValue(Event, options);
+ writer.WritePropertyName("rateCondition"u8);
+ writer.WriteStringValue(RateCondition);
+ }
+
+ EventRateDefinition 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(EventRateDefinition)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeEventRateDefinition(document.RootElement, options);
+ }
+
+ internal static EventRateDefinition DeserializeEventRateDefinition(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ ObservedEvent @event = default;
+ string rateCondition = default;
+ MetricType type = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("event"u8))
+ {
+ @event = ObservedEvent.DeserializeObservedEvent(property.Value, options);
+ continue;
+ }
+ if (property.NameEquals("rateCondition"u8))
+ {
+ rateCondition = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("type"u8))
+ {
+ type = new MetricType(property.Value.GetString());
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new EventRateDefinition(type, serializedAdditionalRawData, @event, rateCondition);
+ }
+
+ 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(EventRateDefinition)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ EventRateDefinition 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 DeserializeEventRateDefinition(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(EventRateDefinition)} 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 EventRateDefinition FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeEventRateDefinition(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/onlineexperimentation/onlineexperimentation/src/Generated/EventRateDefinition.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/EventRateDefinition.cs
new file mode 100644
index 000000000000..b6f00d78c387
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/EventRateDefinition.cs
@@ -0,0 +1,51 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+
+namespace Azure.Analytics.OnlineExperimentation
+{
+ /// The definition of an EventRate metric. This metric type counts the percentage of events that satisfy a condition.
+ public partial class EventRateDefinition : ExperimentMetricDefinition
+ {
+ /// Initializes a new instance of .
+ /// Event to observe as the rate denominator.
+ /// The event contributes to the rate numerator if it satisfies this condition.
+ /// or is null.
+ public EventRateDefinition(ObservedEvent @event, string rateCondition)
+ {
+ Argument.AssertNotNull(@event, nameof(@event));
+ Argument.AssertNotNull(rateCondition, nameof(rateCondition));
+
+ Type = MetricType.EventRate;
+ Event = @event;
+ RateCondition = rateCondition;
+ }
+
+ /// Initializes a new instance of .
+ /// Discriminator property for ExperimentMetricDefinition.
+ /// Keeps track of any properties unknown to the library.
+ /// Event to observe as the rate denominator.
+ /// The event contributes to the rate numerator if it satisfies this condition.
+ internal EventRateDefinition(MetricType type, IDictionary serializedAdditionalRawData, ObservedEvent @event, string rateCondition) : base(type, serializedAdditionalRawData)
+ {
+ Event = @event;
+ RateCondition = rateCondition;
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal EventRateDefinition()
+ {
+ }
+
+ /// Event to observe as the rate denominator.
+ public ObservedEvent Event { get; set; }
+ /// The event contributes to the rate numerator if it satisfies this condition.
+ public string RateCondition { get; set; }
+ }
+}
diff --git a/sdk/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetric.Serialization.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetric.Serialization.cs
new file mode 100644
index 000000000000..112b36a076b1
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetric.Serialization.cs
@@ -0,0 +1,235 @@
+// 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.Analytics.OnlineExperimentation
+{
+ public partial class ExperimentMetric : 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(ExperimentMetric)} does not support writing '{format}' format.");
+ }
+
+ if (options.Format != "W")
+ {
+ writer.WritePropertyName("id"u8);
+ writer.WriteStringValue(Id);
+ }
+ writer.WritePropertyName("lifecycle"u8);
+ writer.WriteStringValue(Lifecycle.ToString());
+ writer.WritePropertyName("displayName"u8);
+ writer.WriteStringValue(DisplayName);
+ writer.WritePropertyName("description"u8);
+ writer.WriteStringValue(Description);
+ writer.WritePropertyName("categories"u8);
+ writer.WriteStartArray();
+ foreach (var item in Categories)
+ {
+ writer.WriteStringValue(item);
+ }
+ writer.WriteEndArray();
+ writer.WritePropertyName("desiredDirection"u8);
+ writer.WriteStringValue(DesiredDirection.ToString());
+ writer.WritePropertyName("definition"u8);
+ writer.WriteObjectValue(Definition, options);
+ if (options.Format != "W")
+ {
+ writer.WritePropertyName("eTag"u8);
+ writer.WriteStringValue(ETag.ToString());
+ }
+ if (options.Format != "W")
+ {
+ writer.WritePropertyName("lastModifiedAt"u8);
+ writer.WriteStringValue(LastModifiedAt, "O");
+ }
+ if (options.Format != "W" && _serializedAdditionalRawData != null)
+ {
+ foreach (var item in _serializedAdditionalRawData)
+ {
+ writer.WritePropertyName(item.Key);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(item.Value);
+#else
+ using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ }
+
+ ExperimentMetric 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(ExperimentMetric)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeExperimentMetric(document.RootElement, options);
+ }
+
+ internal static ExperimentMetric DeserializeExperimentMetric(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ string id = default;
+ LifecycleStage lifecycle = default;
+ string displayName = default;
+ string description = default;
+ IList categories = default;
+ DesiredDirection desiredDirection = default;
+ ExperimentMetricDefinition definition = default;
+ ETag eTag = default;
+ DateTimeOffset lastModifiedAt = 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("lifecycle"u8))
+ {
+ lifecycle = new LifecycleStage(property.Value.GetString());
+ continue;
+ }
+ if (property.NameEquals("displayName"u8))
+ {
+ displayName = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("description"u8))
+ {
+ description = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("categories"u8))
+ {
+ List array = new List();
+ foreach (var item in property.Value.EnumerateArray())
+ {
+ array.Add(item.GetString());
+ }
+ categories = array;
+ continue;
+ }
+ if (property.NameEquals("desiredDirection"u8))
+ {
+ desiredDirection = new DesiredDirection(property.Value.GetString());
+ continue;
+ }
+ if (property.NameEquals("definition"u8))
+ {
+ definition = ExperimentMetricDefinition.DeserializeExperimentMetricDefinition(property.Value, options);
+ continue;
+ }
+ if (property.NameEquals("eTag"u8))
+ {
+ eTag = new ETag(property.Value.GetString());
+ continue;
+ }
+ if (property.NameEquals("lastModifiedAt"u8))
+ {
+ lastModifiedAt = property.Value.GetDateTimeOffset("O");
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new ExperimentMetric(
+ id,
+ lifecycle,
+ displayName,
+ description,
+ categories,
+ desiredDirection,
+ definition,
+ eTag,
+ lastModifiedAt,
+ 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(ExperimentMetric)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ ExperimentMetric 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 DeserializeExperimentMetric(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(ExperimentMetric)} 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 ExperimentMetric FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeExperimentMetric(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/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetric.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetric.cs
new file mode 100644
index 000000000000..854b176e22fb
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetric.cs
@@ -0,0 +1,133 @@
+// 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.Analytics.OnlineExperimentation
+{
+ /// A ExperimentMetric object that describes the metric.
+ public partial class ExperimentMetric
+ {
+ ///
+ /// 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 stage in the metric lifecycle, which determines when the metric is calculated.
+ /// A display name for the metric to use for display rather than the ID.
+ /// A description of the metric.
+ /// The categories of the metric.
+ /// Whether an increase or decrease to the metric value is desired.
+ ///
+ /// The metric definition, which determines how the metric value is calculated from event data.
+ /// 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 .
+ ///
+ /// , , or is null.
+ public ExperimentMetric(LifecycleStage lifecycle, string displayName, string description, IEnumerable categories, DesiredDirection desiredDirection, ExperimentMetricDefinition definition)
+ {
+ Argument.AssertNotNull(displayName, nameof(displayName));
+ Argument.AssertNotNull(description, nameof(description));
+ Argument.AssertNotNull(categories, nameof(categories));
+ Argument.AssertNotNull(definition, nameof(definition));
+
+ Lifecycle = lifecycle;
+ DisplayName = displayName;
+ Description = description;
+ Categories = categories.ToList();
+ DesiredDirection = desiredDirection;
+ Definition = definition;
+ }
+
+ /// Initializes a new instance of .
+ /// An ID used to uniquely identify and reference the metric.
+ /// The stage in the metric lifecycle, which determines when the metric is calculated.
+ /// A display name for the metric to use for display rather than the ID.
+ /// A description of the metric.
+ /// The categories of the metric.
+ /// Whether an increase or decrease to the metric value is desired.
+ ///
+ /// The metric definition, which determines how the metric value is calculated from event data.
+ /// 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 .
+ ///
+ /// ETag of the metric.
+ /// The timestamp of resource last modification (UTC).
+ /// Keeps track of any properties unknown to the library.
+ internal ExperimentMetric(string id, LifecycleStage lifecycle, string displayName, string description, IList categories, DesiredDirection desiredDirection, ExperimentMetricDefinition definition, ETag eTag, DateTimeOffset lastModifiedAt, IDictionary serializedAdditionalRawData)
+ {
+ Id = id;
+ Lifecycle = lifecycle;
+ DisplayName = displayName;
+ Description = description;
+ Categories = categories;
+ DesiredDirection = desiredDirection;
+ Definition = definition;
+ ETag = eTag;
+ LastModifiedAt = lastModifiedAt;
+ _serializedAdditionalRawData = serializedAdditionalRawData;
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal ExperimentMetric()
+ {
+ }
+
+ /// An ID used to uniquely identify and reference the metric.
+ public string Id { get; }
+ /// The stage in the metric lifecycle, which determines when the metric is calculated.
+ public LifecycleStage Lifecycle { get; set; }
+ /// A display name for the metric to use for display rather than the ID.
+ public string DisplayName { get; set; }
+ /// A description of the metric.
+ public string Description { get; set; }
+ /// The categories of the metric.
+ public IList Categories { get; }
+ /// Whether an increase or decrease to the metric value is desired.
+ public DesiredDirection DesiredDirection { get; set; }
+ ///
+ /// The metric definition, which determines how the metric value is calculated from event data.
+ /// 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 ExperimentMetricDefinition Definition { get; set; }
+ /// ETag of the metric.
+ public ETag ETag { get; }
+ /// The timestamp of resource last modification (UTC).
+ public DateTimeOffset LastModifiedAt { get; }
+ }
+}
diff --git a/sdk/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetricDefinition.Serialization.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetricDefinition.Serialization.cs
new file mode 100644
index 000000000000..afb7c818d0f6
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetricDefinition.Serialization.cs
@@ -0,0 +1,139 @@
+// 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.Analytics.OnlineExperimentation
+{
+ [PersistableModelProxy(typeof(UnknownExperimentMetricDefinition))]
+ public partial class ExperimentMetricDefinition : 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(ExperimentMetricDefinition)} 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
+ }
+ }
+ }
+
+ ExperimentMetricDefinition 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(ExperimentMetricDefinition)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeExperimentMetricDefinition(document.RootElement, options);
+ }
+
+ internal static ExperimentMetricDefinition DeserializeExperimentMetricDefinition(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 "Average": return AverageDefinition.DeserializeAverageDefinition(element, options);
+ case "EventCount": return EventCountDefinition.DeserializeEventCountDefinition(element, options);
+ case "EventRate": return EventRateDefinition.DeserializeEventRateDefinition(element, options);
+ case "Percentile": return PercentileDefinition.DeserializePercentileDefinition(element, options);
+ case "Sum": return SumDefinition.DeserializeSumDefinition(element, options);
+ case "UserCount": return UserCountDefinition.DeserializeUserCountDefinition(element, options);
+ case "UserRate": return UserRateDefinition.DeserializeUserRateDefinition(element, options);
+ }
+ }
+ return UnknownExperimentMetricDefinition.DeserializeUnknownExperimentMetricDefinition(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(ExperimentMetricDefinition)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ ExperimentMetricDefinition 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 DeserializeExperimentMetricDefinition(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(ExperimentMetricDefinition)} 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 ExperimentMetricDefinition FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeExperimentMetricDefinition(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/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetricDefinition.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetricDefinition.cs
new file mode 100644
index 000000000000..1040ed4e84bd
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetricDefinition.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.Analytics.OnlineExperimentation
+{
+ ///
+ /// The metric definition, which determines how the metric value is calculated from event data.
+ /// 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 ExperimentMetricDefinition
+ {
+ ///
+ /// 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 ExperimentMetricDefinition()
+ {
+ }
+
+ /// Initializes a new instance of .
+ /// Discriminator property for ExperimentMetricDefinition.
+ /// Keeps track of any properties unknown to the library.
+ internal ExperimentMetricDefinition(MetricType type, IDictionary serializedAdditionalRawData)
+ {
+ Type = type;
+ _serializedAdditionalRawData = serializedAdditionalRawData;
+ }
+
+ /// Discriminator property for ExperimentMetricDefinition.
+ internal MetricType Type { get; set; }
+ }
+}
diff --git a/sdk/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetricValidateResult.Serialization.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetricValidateResult.Serialization.cs
new file mode 100644
index 000000000000..62e3aef42662
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetricValidateResult.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.Analytics.OnlineExperimentation
+{
+ public partial class ExperimentMetricValidateResult : 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(ExperimentMetricValidateResult)} does not support writing '{format}' format.");
+ }
+
+ if (options.Format != "W")
+ {
+ writer.WritePropertyName("diagnostics"u8);
+ writer.WriteStartArray();
+ foreach (var item in Diagnostics)
+ {
+ writer.WriteObjectValue(item, options);
+ }
+ writer.WriteEndArray();
+ }
+ writer.WritePropertyName("result"u8);
+ writer.WriteStringValue(Result.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
+ }
+ }
+ }
+
+ ExperimentMetricValidateResult 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(ExperimentMetricValidateResult)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeExperimentMetricValidateResult(document.RootElement, options);
+ }
+
+ internal static ExperimentMetricValidateResult DeserializeExperimentMetricValidateResult(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ IReadOnlyList diagnostics = default;
+ ValidationResultOption result = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("diagnostics"u8))
+ {
+ List array = new List();
+ foreach (var item in property.Value.EnumerateArray())
+ {
+ array.Add(DiagnosticInfo.DeserializeDiagnosticInfo(item, options));
+ }
+ diagnostics = array;
+ continue;
+ }
+ if (property.NameEquals("result"u8))
+ {
+ result = new ValidationResultOption(property.Value.GetString());
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new ExperimentMetricValidateResult(diagnostics, result, 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(ExperimentMetricValidateResult)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ ExperimentMetricValidateResult 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 DeserializeExperimentMetricValidateResult(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(ExperimentMetricValidateResult)} 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 ExperimentMetricValidateResult FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeExperimentMetricValidateResult(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/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetricValidateResult.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetricValidateResult.cs
new file mode 100644
index 000000000000..06e8dd829cdb
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetricValidateResult.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.Analytics.OnlineExperimentation
+{
+ /// The result of validating a metric.
+ public partial class ExperimentMetricValidateResult
+ {
+ ///
+ /// 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 .
+ /// Whether the metric is valid.
+ internal ExperimentMetricValidateResult(ValidationResultOption result)
+ {
+ Diagnostics = new ChangeTrackingList();
+ Result = result;
+ }
+
+ /// Initializes a new instance of .
+ /// The validation result.
+ /// Whether the metric is valid.
+ /// Keeps track of any properties unknown to the library.
+ internal ExperimentMetricValidateResult(IReadOnlyList diagnostics, ValidationResultOption result, IDictionary serializedAdditionalRawData)
+ {
+ Diagnostics = diagnostics;
+ Result = result;
+ _serializedAdditionalRawData = serializedAdditionalRawData;
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal ExperimentMetricValidateResult()
+ {
+ }
+
+ /// The validation result.
+ public IReadOnlyList Diagnostics { get; }
+ /// Whether the metric is valid.
+ public ValidationResultOption Result { get; }
+ }
+}
diff --git a/sdk/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetrics.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetrics.cs
new file mode 100644
index 000000000000..bc773d79d9dd
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/ExperimentMetrics.cs
@@ -0,0 +1,633 @@
+// 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.Analytics.OnlineExperimentation
+{
+ // Data plane generated sub-client.
+ /// The ExperimentMetrics sub-client.
+ public partial class ExperimentMetrics
+ {
+ private static readonly string[] AuthorizationScopes = new string[] { "https://exp.azure.net/.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 ExperimentMetrics for mocking.
+ protected ExperimentMetrics()
+ {
+ }
+
+ /// Initializes a new instance of ExperimentMetrics.
+ /// The handler for diagnostic messaging in the client.
+ /// The HTTP pipeline for sending and receiving REST requests and responses.
+ /// The token credential to copy.
+ /// Endpoint URL for the Online Experimentation workspace.
+ /// The API version to use for this operation.
+ internal ExperimentMetrics(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, TokenCredential tokenCredential, Uri endpoint, string apiVersion)
+ {
+ ClientDiagnostics = clientDiagnostics;
+ _pipeline = pipeline;
+ _tokenCredential = tokenCredential;
+ _endpoint = endpoint;
+ _apiVersion = apiVersion;
+ }
+
+ /// Fetch a ExperimentMetric by Id.
+ /// An ID used to uniquely identify and reference the metric.
+ /// The content to send as the request conditions of the request.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> GetExperimentMetricAsync(string experimentMetricId, RequestConditions requestConditions = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(experimentMetricId, nameof(experimentMetricId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await GetExperimentMetricAsync(experimentMetricId, requestConditions, context).ConfigureAwait(false);
+ return Response.FromValue(ExperimentMetric.FromResponse(response), response);
+ }
+
+ /// Fetch a ExperimentMetric by Id.
+ /// An ID used to uniquely identify and reference the metric.
+ /// The content to send as the request conditions of the request.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response GetExperimentMetric(string experimentMetricId, RequestConditions requestConditions = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(experimentMetricId, nameof(experimentMetricId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = GetExperimentMetric(experimentMetricId, requestConditions, context);
+ return Response.FromValue(ExperimentMetric.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Fetch a ExperimentMetric by 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.
+ ///
+ ///
+ ///
+ ///
+ /// An ID used to uniquely identify and reference the metric.
+ /// The content to send as the request conditions of the request.
+ /// 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 GetExperimentMetricAsync(string experimentMetricId, RequestConditions requestConditions, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(experimentMetricId, nameof(experimentMetricId));
+
+ using var scope = ClientDiagnostics.CreateScope("ExperimentMetrics.GetExperimentMetric");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetExperimentMetricRequest(experimentMetricId, requestConditions, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Fetch a ExperimentMetric by 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.
+ ///
+ ///
+ ///
+ ///
+ /// An ID used to uniquely identify and reference the metric.
+ /// The content to send as the request conditions of the request.
+ /// 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 GetExperimentMetric(string experimentMetricId, RequestConditions requestConditions, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(experimentMetricId, nameof(experimentMetricId));
+
+ using var scope = ClientDiagnostics.CreateScope("ExperimentMetrics.GetExperimentMetric");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetExperimentMetricRequest(experimentMetricId, requestConditions, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Creates or updates a ExperimentMetric asynchronously.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// An ID used to uniquely identify and reference the metric.
+ /// The content to send as the body of the request.
+ /// The content to send as the request conditions 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 CreateOrUpdateAsync(string experimentMetricId, RequestContent content, RequestConditions requestConditions = null, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(experimentMetricId, nameof(experimentMetricId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("ExperimentMetrics.CreateOrUpdate");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCreateOrUpdateRequest(experimentMetricId, content, requestConditions, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Creates or updates a ExperimentMetric asynchronously.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// An ID used to uniquely identify and reference the metric.
+ /// The content to send as the body of the request.
+ /// The content to send as the request conditions 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 CreateOrUpdate(string experimentMetricId, RequestContent content, RequestConditions requestConditions = null, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(experimentMetricId, nameof(experimentMetricId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("ExperimentMetrics.CreateOrUpdate");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCreateOrUpdateRequest(experimentMetricId, content, requestConditions, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Validates a ExperimentMetric.
+ /// An ID used to uniquely identify and reference the metric.
+ /// Metric input to validate.
+ /// The cancellation token to use.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> ValidateAsync(string experimentMetricId, ExperimentMetric body, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(experimentMetricId, nameof(experimentMetricId));
+ Argument.AssertNotNull(body, nameof(body));
+
+ using RequestContent content = body.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await ValidateAsync(experimentMetricId, content, context).ConfigureAwait(false);
+ return Response.FromValue(ExperimentMetricValidateResult.FromResponse(response), response);
+ }
+
+ /// Validates a ExperimentMetric.
+ /// An ID used to uniquely identify and reference the metric.
+ /// Metric input to validate.
+ /// The cancellation token to use.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response Validate(string experimentMetricId, ExperimentMetric body, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(experimentMetricId, nameof(experimentMetricId));
+ Argument.AssertNotNull(body, nameof(body));
+
+ using RequestContent content = body.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = Validate(experimentMetricId, content, context);
+ return Response.FromValue(ExperimentMetricValidateResult.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Validates a ExperimentMetric.
+ ///
+ /// -
+ ///
+ /// 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.
+ ///
+ ///
+ ///
+ ///
+ /// An ID used to uniquely identify and reference the metric.
+ /// 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 ValidateAsync(string experimentMetricId, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(experimentMetricId, nameof(experimentMetricId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("ExperimentMetrics.Validate");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateValidateRequest(experimentMetricId, content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Validates a ExperimentMetric.
+ ///
+ /// -
+ ///
+ /// 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.
+ ///
+ ///
+ ///
+ ///
+ /// An ID used to uniquely identify and reference the metric.
+ /// 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 Validate(string experimentMetricId, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(experimentMetricId, nameof(experimentMetricId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("ExperimentMetrics.Validate");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateValidateRequest(experimentMetricId, 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] Delete a ExperimentMetric asynchronously.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// An ID used to uniquely identify and reference the metric.
+ /// The content to send as the request conditions of the request.
+ /// 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 DeleteAsync(string experimentMetricId, RequestConditions requestConditions = null, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(experimentMetricId, nameof(experimentMetricId));
+
+ using var scope = ClientDiagnostics.CreateScope("ExperimentMetrics.Delete");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateDeleteRequest(experimentMetricId, requestConditions, 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 a ExperimentMetric asynchronously.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// An ID used to uniquely identify and reference the metric.
+ /// The content to send as the request conditions of the request.
+ /// 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 Delete(string experimentMetricId, RequestConditions requestConditions = null, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(experimentMetricId, nameof(experimentMetricId));
+
+ using var scope = ClientDiagnostics.CreateScope("ExperimentMetrics.Delete");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateDeleteRequest(experimentMetricId, requestConditions, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// List ExperimentMetric resources.
+ /// The cancellation token to use.
+ ///
+ public virtual AsyncPageable GetExperimentMetricsAsync(CancellationToken cancellationToken = default)
+ {
+ RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null;
+ HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetExperimentMetricsRequest(context);
+ HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetExperimentMetricsNextPageRequest(nextLink, context);
+ return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => ExperimentMetric.DeserializeExperimentMetric(e), ClientDiagnostics, _pipeline, "ExperimentMetrics.GetExperimentMetrics", "value", "nextLink", context);
+ }
+
+ /// List ExperimentMetric resources.
+ /// The cancellation token to use.
+ ///
+ public virtual Pageable GetExperimentMetrics(CancellationToken cancellationToken = default)
+ {
+ RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null;
+ HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetExperimentMetricsRequest(context);
+ HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetExperimentMetricsNextPageRequest(nextLink, context);
+ return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => ExperimentMetric.DeserializeExperimentMetric(e), ClientDiagnostics, _pipeline, "ExperimentMetrics.GetExperimentMetrics", "value", "nextLink", context);
+ }
+
+ ///
+ /// [Protocol Method] List ExperimentMetric resources
+ ///
+ /// -
+ ///
+ /// 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 GetExperimentMetricsAsync(RequestContext context)
+ {
+ HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetExperimentMetricsRequest(context);
+ HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetExperimentMetricsNextPageRequest(nextLink, context);
+ return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "ExperimentMetrics.GetExperimentMetrics", "value", "nextLink", context);
+ }
+
+ ///
+ /// [Protocol Method] List ExperimentMetric resources
+ ///
+ /// -
+ ///
+ /// 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 GetExperimentMetrics(RequestContext context)
+ {
+ HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetExperimentMetricsRequest(context);
+ HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetExperimentMetricsNextPageRequest(nextLink, context);
+ return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "ExperimentMetrics.GetExperimentMetrics", "value", "nextLink", context);
+ }
+
+ internal HttpMessage CreateGetExperimentMetricRequest(string experimentMetricId, RequestConditions requestConditions, 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("/experiment-metrics/", false);
+ uri.AppendPath(experimentMetricId, true);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ if (requestConditions != null)
+ {
+ request.Headers.Add(requestConditions, "R");
+ }
+ return message;
+ }
+
+ internal HttpMessage CreateCreateOrUpdateRequest(string experimentMetricId, RequestContent content, RequestConditions requestConditions, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier200201);
+ var request = message.Request;
+ request.Method = RequestMethod.Patch;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendPath("/experiment-metrics/", false);
+ uri.AppendPath(experimentMetricId, true);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ if (requestConditions != null)
+ {
+ request.Headers.Add(requestConditions, "R");
+ }
+ request.Headers.Add("Content-Type", "application/merge-patch+json");
+ request.Content = content;
+ return message;
+ }
+
+ internal HttpMessage CreateValidateRequest(string experimentMetricId, 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("/experiment-metrics/", false);
+ uri.AppendPath(experimentMetricId, true);
+ uri.AppendPath(":validate", 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 CreateDeleteRequest(string experimentMetricId, RequestConditions requestConditions, 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("/experiment-metrics/", false);
+ uri.AppendPath(experimentMetricId, true);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ if (requestConditions != null)
+ {
+ request.Headers.Add(requestConditions, "R");
+ }
+ return message;
+ }
+
+ internal HttpMessage CreateGetExperimentMetricsRequest(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("/experiment-metrics", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ return message;
+ }
+
+ internal HttpMessage CreateGetExperimentMetricsNextPageRequest(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 _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/onlineexperimentation/onlineexperimentation/src/Generated/Internal/Argument.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/Internal/Argument.cs
new file mode 100644
index 000000000000..b6a0f18d3d7c
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/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.Analytics.OnlineExperimentation
+{
+ 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/onlineexperimentation/onlineexperimentation/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/Internal/ChangeTrackingDictionary.cs
new file mode 100644
index 000000000000..2faf429e0521
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/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.Analytics.OnlineExperimentation
+{
+ 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/onlineexperimentation/onlineexperimentation/src/Generated/Internal/ChangeTrackingList.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/Internal/ChangeTrackingList.cs
new file mode 100644
index 000000000000..9599d0cee8d3
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/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.Analytics.OnlineExperimentation
+{
+ 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/onlineexperimentation/onlineexperimentation/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/onlineexperimentation/onlineexperimentation/src/Generated/Internal/ModelSerializationExtensions.cs
new file mode 100644
index 000000000000..c19512698070
--- /dev/null
+++ b/sdk/onlineexperimentation/onlineexperimentation/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.Analytics.OnlineExperimentation
+{
+ 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