diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/Azure.Developer.LoadTesting.sln b/sdk/loadtesting/Azure.Developer.LoadTesting/Azure.Developer.LoadTesting.sln new file mode 100644 index 000000000000..a8b49668a2eb --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/Azure.Developer.LoadTesting.sln @@ -0,0 +1,54 @@ +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.Developer.LoadTesting", "src\Azure.Developer.LoadTesting.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +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/loadtesting/Azure.Developer.LoadTesting/CHANGELOG.md b/sdk/loadtesting/Azure.Developer.LoadTesting/CHANGELOG.md new file mode 100644 index 000000000000..8b33f0fedccc --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/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/loadtesting/Azure.Developer.LoadTesting/Directory.Build.props b/sdk/loadtesting/Azure.Developer.LoadTesting/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/README.md b/sdk/loadtesting/Azure.Developer.LoadTesting/README.md new file mode 100644 index 000000000000..09c7f0c5f2cd --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/README.md @@ -0,0 +1,107 @@ +# Azure.Developer.LoadTesting client library for .NET + +Azure.Developer.LoadTesting 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/loadtesting/Azure.Developer.LoadTesting/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.Developer.LoadTesting --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/loadtesting/Azure.Developer.LoadTesting/samples). + +## Troubleshooting + +Describe common errors and exceptions, how to "unpack" them if necessary, and include guidance for graceful handling and recovery. + +Provide information to help developers avoid throttling or other service-enforced errors they might encounter. For example, provide guidance and examples for using retry or connection policies in the API. + +If the package or a related package supports it, include tips for logging or enabling instrumentation to help them debug their code. + +## Next steps + +* Provide a link to additional code examples, ideally to those sitting alongside the README in the package's `/samples` directory. +* If appropriate, point users to other packages that might be useful. +* If you think there's a good chance that developers might stumble across your package in error (because they're searching for specific functionality and mistakenly think the package provides that functionality), point them to the packages they might be looking for. + +## Contributing + +This is a template, but your SDK readme should include details on how to contribute code to the repo/package. + + +[style-guide-msft]: https://docs.microsoft.com/style-guide/capitalization +[style-guide-cloud]: https://aka.ms/azsdk/cloud-style-guide + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-net/sdk/loadtesting/Azure.Developer.LoadTesting/README.png) \ No newline at end of file diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Azure.Developer.LoadTesting.csproj b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Azure.Developer.LoadTesting.csproj new file mode 100644 index 000000000000..e46421196dcf --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Azure.Developer.LoadTesting.csproj @@ -0,0 +1,19 @@ + + + This is the Azure.Developer.LoadTesting client library for developing .NET applications with rich experience. + Azure SDK Code Generation Azure.Developer.LoadTesting for Azure Data Plane + 1.0.0-beta.1 + Azure.Developer.LoadTesting + $(RequiredTargetFrameworks) + true + + + + + + + + + + + diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/AggregationType.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/AggregationType.cs new file mode 100644 index 000000000000..76917e3b3797 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/AggregationType.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Aggregation type. + public readonly partial struct AggregationType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AggregationType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AverageValue = "Average"; + private const string CountValue = "Count"; + private const string NoneValue = "None"; + private const string TotalValue = "Total"; + private const string Percentile75Value = "Percentile75"; + private const string Percentile90Value = "Percentile90"; + private const string Percentile95Value = "Percentile95"; + private const string Percentile96Value = "Percentile96"; + private const string Percentile97Value = "Percentile97"; + private const string Percentile98Value = "Percentile98"; + private const string Percentile99Value = "Percentile99"; + private const string Percentile999Value = "Percentile999"; + private const string Percentile9999Value = "Percentile9999"; + + /// Average value. + public static AggregationType Average { get; } = new AggregationType(AverageValue); + /// Total count. + public static AggregationType Count { get; } = new AggregationType(CountValue); + /// Aggregation will be average in this case. + public static AggregationType None { get; } = new AggregationType(NoneValue); + /// Total sum. + public static AggregationType Total { get; } = new AggregationType(TotalValue); + /// 75th percentile. + public static AggregationType Percentile75 { get; } = new AggregationType(Percentile75Value); + /// 90th percentile. + public static AggregationType Percentile90 { get; } = new AggregationType(Percentile90Value); + /// 95th percentile. + public static AggregationType Percentile95 { get; } = new AggregationType(Percentile95Value); + /// 96th percentile. + public static AggregationType Percentile96 { get; } = new AggregationType(Percentile96Value); + /// 97th percentile. + public static AggregationType Percentile97 { get; } = new AggregationType(Percentile97Value); + /// 98th percentile. + public static AggregationType Percentile98 { get; } = new AggregationType(Percentile98Value); + /// 99th percentile. + public static AggregationType Percentile99 { get; } = new AggregationType(Percentile99Value); + /// 99.9th percentile. + public static AggregationType Percentile999 { get; } = new AggregationType(Percentile999Value); + /// 99.99th percentile. + public static AggregationType Percentile9999 { get; } = new AggregationType(Percentile9999Value); + /// Determines if two values are the same. + public static bool operator ==(AggregationType left, AggregationType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AggregationType left, AggregationType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AggregationType(string value) => new AggregationType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AggregationType other && Equals(other); + /// + public bool Equals(AggregationType 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/ArtifactsContainerInfo.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ArtifactsContainerInfo.Serialization.cs new file mode 100644 index 000000000000..ccdf31a21bfe --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ArtifactsContainerInfo.Serialization.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class ArtifactsContainerInfo : 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(ArtifactsContainerInfo)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Uri)) + { + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Uri.AbsoluteUri); + } + if (Optional.IsDefined(ExpiresOn)) + { + writer.WritePropertyName("expireDateTime"u8); + writer.WriteStringValue(ExpiresOn.Value, "O"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ArtifactsContainerInfo 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(ArtifactsContainerInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeArtifactsContainerInfo(document.RootElement, options); + } + + internal static ArtifactsContainerInfo DeserializeArtifactsContainerInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Uri url = default; + DateTimeOffset? expireDateTime = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("url"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + url = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("expireDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expireDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ArtifactsContainerInfo(url, expireDateTime, 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(ArtifactsContainerInfo)} does not support writing '{options.Format}' format."); + } + } + + ArtifactsContainerInfo 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 DeserializeArtifactsContainerInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ArtifactsContainerInfo)} 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 ArtifactsContainerInfo FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeArtifactsContainerInfo(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/ArtifactsContainerInfo.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ArtifactsContainerInfo.cs new file mode 100644 index 000000000000..6c3025c73388 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ArtifactsContainerInfo.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.Developer.LoadTesting +{ + /// Artifacts container info. + public partial class ArtifactsContainerInfo + { + /// + /// 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 ArtifactsContainerInfo() + { + } + + /// Initializes a new instance of . + /// This is a SAS URI to an Azure Storage Container that contains the test run artifacts. + /// Expiry time of the container (RFC 3339 literal format). + /// Keeps track of any properties unknown to the library. + internal ArtifactsContainerInfo(Uri uri, DateTimeOffset? expiresOn, IDictionary serializedAdditionalRawData) + { + Uri = uri; + ExpiresOn = expiresOn; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// This is a SAS URI to an Azure Storage Container that contains the test run artifacts. + public Uri Uri { get; } + /// Expiry time of the container (RFC 3339 literal format). + public DateTimeOffset? ExpiresOn { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/AutoStopCriteria.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/AutoStopCriteria.Serialization.cs new file mode 100644 index 000000000000..748a067e8600 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/AutoStopCriteria.Serialization.cs @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class AutoStopCriteria : 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(AutoStopCriteria)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(AutoStopDisabled)) + { + writer.WritePropertyName("autoStopDisabled"u8); + writer.WriteBooleanValue(AutoStopDisabled.Value); + } + if (Optional.IsDefined(ErrorRate)) + { + writer.WritePropertyName("errorRate"u8); + writer.WriteNumberValue(ErrorRate.Value); + } + if (Optional.IsDefined(ErrorRateTimeWindow)) + { + writer.WritePropertyName("errorRateTimeWindowInSeconds"u8); + writer.WriteNumberValue(Convert.ToInt32(ErrorRateTimeWindow.Value.ToString("%s"))); + } + if (Optional.IsDefined(MaximumVirtualUsersPerEngine)) + { + writer.WritePropertyName("maximumVirtualUsersPerEngine"u8); + writer.WriteNumberValue(MaximumVirtualUsersPerEngine.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AutoStopCriteria 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(AutoStopCriteria)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAutoStopCriteria(document.RootElement, options); + } + + internal static AutoStopCriteria DeserializeAutoStopCriteria(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? autoStopDisabled = default; + float? errorRate = default; + TimeSpan? errorRateTimeWindowInSeconds = default; + int? maximumVirtualUsersPerEngine = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("autoStopDisabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + autoStopDisabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("errorRate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + errorRate = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("errorRateTimeWindowInSeconds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + errorRateTimeWindowInSeconds = TimeSpan.FromSeconds(property.Value.GetInt32()); + continue; + } + if (property.NameEquals("maximumVirtualUsersPerEngine"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maximumVirtualUsersPerEngine = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AutoStopCriteria(autoStopDisabled, errorRate, errorRateTimeWindowInSeconds, maximumVirtualUsersPerEngine, 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(AutoStopCriteria)} does not support writing '{options.Format}' format."); + } + } + + AutoStopCriteria 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 DeserializeAutoStopCriteria(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AutoStopCriteria)} 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 AutoStopCriteria FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAutoStopCriteria(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/AutoStopCriteria.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/AutoStopCriteria.cs new file mode 100644 index 000000000000..5acc1601f85f --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/AutoStopCriteria.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.Developer.LoadTesting +{ + /// Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. + public partial class AutoStopCriteria + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public AutoStopCriteria() + { + } + + /// Initializes a new instance of . + /// Whether auto-stop should be disabled. The default value is false. + /// Threshold percentage of errors on which test run should be automatically stopped. Allowed values are in range of 0.0-100.0. + /// Time window during which the error percentage should be evaluated in seconds. + /// Maximum number of virtual users per load testing engine, at which the test run should be automatically stopped. + /// Keeps track of any properties unknown to the library. + internal AutoStopCriteria(bool? autoStopDisabled, float? errorRate, TimeSpan? errorRateTimeWindow, int? maximumVirtualUsersPerEngine, IDictionary serializedAdditionalRawData) + { + AutoStopDisabled = autoStopDisabled; + ErrorRate = errorRate; + ErrorRateTimeWindow = errorRateTimeWindow; + MaximumVirtualUsersPerEngine = maximumVirtualUsersPerEngine; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Whether auto-stop should be disabled. The default value is false. + public bool? AutoStopDisabled { get; set; } + /// Threshold percentage of errors on which test run should be automatically stopped. Allowed values are in range of 0.0-100.0. + public float? ErrorRate { get; set; } + /// Time window during which the error percentage should be evaluated in seconds. + public TimeSpan? ErrorRateTimeWindow { get; set; } + /// Maximum number of virtual users per load testing engine, at which the test run should be automatically stopped. + public int? MaximumVirtualUsersPerEngine { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/AzureDeveloperLoadTestingClientOptions.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/AzureDeveloperLoadTestingClientOptions.cs new file mode 100644 index 000000000000..943585ad18a9 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/AzureDeveloperLoadTestingClientOptions.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + /// Client options for Azure.Developer.LoadTesting library clients. + public partial class AzureDeveloperLoadTestingClientOptions : ClientOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2025_03_01_Preview; + + /// The version of the service to use. + public enum ServiceVersion + { + /// Service version "2022-11-01". + V2022_11_01 = 1, + /// Service version "2023-04-01-preview". + V2023_04_01_Preview = 2, + /// Service version "2024-03-01-preview". + V2024_03_01_Preview = 3, + /// Service version "2024-05-01-preview". + V2024_05_01_Preview = 4, + /// Service version "2024-07-01-preview". + V2024_07_01_Preview = 5, + /// Service version "2024-12-01-preview". + V2024_12_01_Preview = 6, + /// Service version "2025-03-01-preview". + V2025_03_01_Preview = 7, + } + + internal string Version { get; } + + /// Initializes new instance of AzureDeveloperLoadTestingClientOptions. + public AzureDeveloperLoadTestingClientOptions(ServiceVersion version = LatestVersion) + { + Version = version switch + { + ServiceVersion.V2022_11_01 => "2022-11-01", + ServiceVersion.V2023_04_01_Preview => "2023-04-01-preview", + ServiceVersion.V2024_03_01_Preview => "2024-03-01-preview", + ServiceVersion.V2024_05_01_Preview => "2024-05-01-preview", + ServiceVersion.V2024_07_01_Preview => "2024-07-01-preview", + ServiceVersion.V2024_12_01_Preview => "2024-12-01-preview", + ServiceVersion.V2025_03_01_Preview => "2025-03-01-preview", + _ => throw new NotSupportedException() + }; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/CertificateType.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/CertificateType.cs new file mode 100644 index 000000000000..2d4b2cc0ea64 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/CertificateType.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Types of certificates supported. + public readonly partial struct CertificateType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CertificateType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string KeyVaultCertificateUriValue = "AKV_CERT_URI"; + + /// If the certificate is stored in an Azure Key Vault. + public static CertificateType KeyVaultCertificateUri { get; } = new CertificateType(KeyVaultCertificateUriValue); + /// Determines if two values are the same. + public static bool operator ==(CertificateType left, CertificateType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CertificateType left, CertificateType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator CertificateType(string value) => new CertificateType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CertificateType other && Equals(other); + /// + public bool Equals(CertificateType 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/CloneTestRequest1.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/CloneTestRequest1.Serialization.cs new file mode 100644 index 000000000000..21fe0915c78c --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/CloneTestRequest1.Serialization.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + internal partial class CloneTestRequest1 : 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(CloneTestRequest1)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("newTestId"u8); + writer.WriteStringValue(NewTestId); + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && _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 + } + } + } + + CloneTestRequest1 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(CloneTestRequest1)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCloneTestRequest1(document.RootElement, options); + } + + internal static CloneTestRequest1 DeserializeCloneTestRequest1(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string newTestId = default; + string displayName = default; + string description = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("newTestId"u8)) + { + newTestId = 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 (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CloneTestRequest1(newTestId, displayName, description, 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(CloneTestRequest1)} does not support writing '{options.Format}' format."); + } + } + + CloneTestRequest1 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 DeserializeCloneTestRequest1(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CloneTestRequest1)} 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 CloneTestRequest1 FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCloneTestRequest1(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/CloneTestRequest1.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/CloneTestRequest1.cs new file mode 100644 index 000000000000..1360cf440431 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/CloneTestRequest1.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// The CloneTestRequest1. + internal partial class CloneTestRequest1 + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Unique identifier for the new test that will be created. + /// is null. + internal CloneTestRequest1(string newTestId) + { + Argument.AssertNotNull(newTestId, nameof(newTestId)); + + NewTestId = newTestId; + } + + /// Initializes a new instance of . + /// Unique identifier for the new test that will be created. + /// Display Name override for the newly created test. + /// Description override for the newly created test. + /// Keeps track of any properties unknown to the library. + internal CloneTestRequest1(string newTestId, string displayName, string description, IDictionary serializedAdditionalRawData) + { + NewTestId = newTestId; + DisplayName = displayName; + Description = description; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CloneTestRequest1() + { + } + + /// Unique identifier for the new test that will be created. + public string NewTestId { get; } + /// Display Name override for the newly created test. + public string DisplayName { get; } + /// Description override for the newly created test. + public string Description { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/CreatedByType.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/CreatedByType.cs new file mode 100644 index 000000000000..404520f2bea4 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/CreatedByType.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// The type of the entity that created the test run. (E.x. User, ScheduleTrigger, etc). + public readonly partial struct CreatedByType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CreatedByType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UserValue = "User"; + private const string ScheduledTriggerValue = "ScheduledTrigger"; + private const string AzurePipelinesValue = "AzurePipelines"; + private const string GitHubWorkflowsValue = "GitHubWorkflows"; + + /// Entity was created by a user. + public static CreatedByType User { get; } = new CreatedByType(UserValue); + /// Entity was created by a scheduled trigger. + public static CreatedByType ScheduledTrigger { get; } = new CreatedByType(ScheduledTriggerValue); + /// Entity was created by Azure DevOps pipelines. + public static CreatedByType AzurePipelines { get; } = new CreatedByType(AzurePipelinesValue); + /// Entity was created by GitHub Workflows. + public static CreatedByType GitHubWorkflows { get; } = new CreatedByType(GitHubWorkflowsValue); + /// Determines if two values are the same. + public static bool operator ==(CreatedByType left, CreatedByType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CreatedByType left, CreatedByType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator CreatedByType(string value) => new CreatedByType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CreatedByType other && Equals(other); + /// + public bool Equals(CreatedByType 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/DailyRecurrence.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DailyRecurrence.Serialization.cs new file mode 100644 index 000000000000..df17ee5b033d --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DailyRecurrence.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class DailyRecurrence : 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(DailyRecurrence)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("interval"u8); + writer.WriteNumberValue(Interval); + } + + DailyRecurrence 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(DailyRecurrence)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDailyRecurrence(document.RootElement, options); + } + + internal static DailyRecurrence DeserializeDailyRecurrence(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int interval = default; + Frequency frequency = default; + RecurrenceEnd recurrenceEnd = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("interval"u8)) + { + interval = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("frequency"u8)) + { + frequency = new Frequency(property.Value.GetString()); + continue; + } + if (property.NameEquals("recurrenceEnd"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DailyRecurrence(frequency, recurrenceEnd, serializedAdditionalRawData, interval); + } + + 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(DailyRecurrence)} does not support writing '{options.Format}' format."); + } + } + + DailyRecurrence 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 DeserializeDailyRecurrence(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DailyRecurrence)} 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 DailyRecurrence FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDailyRecurrence(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/DailyRecurrence.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DailyRecurrence.cs new file mode 100644 index 000000000000..08c6091d643b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DailyRecurrence.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Recurrence model when frequency is set as Daily. + public partial class DailyRecurrence : Recurrence + { + /// Initializes a new instance of . + /// The interval at which the recurrence should repeat. It signifies the number of days between each recurrence. + public DailyRecurrence(int interval) + { + Frequency = Frequency.Daily; + Interval = interval; + } + + /// Initializes a new instance of . + /// Frequency of the recurrence. + /// Recurrence end model. You can specify the end either by providing a numberOfOccurrences (which will end the recurrence after the specified number of occurrences) or by providing an endDateTime (which will end the recurrence after the specified date). If neither value is provided, the recurrence will continue until it is manually ended. However, if both values are provided, an error will be thrown. + /// Keeps track of any properties unknown to the library. + /// The interval at which the recurrence should repeat. It signifies the number of days between each recurrence. + internal DailyRecurrence(Frequency frequency, RecurrenceEnd recurrenceEnd, IDictionary serializedAdditionalRawData, int interval) : base(frequency, recurrenceEnd, serializedAdditionalRawData) + { + Interval = interval; + } + + /// Initializes a new instance of for deserialization. + internal DailyRecurrence() + { + } + + /// The interval at which the recurrence should repeat. It signifies the number of days between each recurrence. + public int Interval { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DeveloperLoadTestingClientBuilderExtensions.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DeveloperLoadTestingClientBuilderExtensions.cs new file mode 100644 index 000000000000..6d76257f95b6 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DeveloperLoadTestingClientBuilderExtensions.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core.Extensions; +using Azure.Developer.LoadTesting; + +namespace Microsoft.Extensions.Azure +{ + /// Extension methods to add , to client builder. + public static partial class DeveloperLoadTestingClientBuilderExtensions + { + /// Registers a instance. + /// The builder to register with. + /// The to use. + public static IAzureClientBuilder AddLoadTestAdministrationClient(this TBuilder builder, Uri endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential + { + return builder.RegisterClientFactory((options, cred) => new LoadTestAdministrationClient(endpoint, cred, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The to use. + public static IAzureClientBuilder AddLoadTestRunClient(this TBuilder builder, Uri endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential + { + return builder.RegisterClientFactory((options, cred) => new LoadTestRunClient(endpoint, cred, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddLoadTestAdministrationClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddLoadTestRunClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DeveloperLoadTestingModelFactory.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DeveloperLoadTestingModelFactory.cs new file mode 100644 index 000000000000..472264a14192 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DeveloperLoadTestingModelFactory.cs @@ -0,0 +1,936 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + /// Model factory for models. + public static partial class DeveloperLoadTestingModelFactory + { + /// Initializes a new instance of . + /// Pass fail criteria for a test. + /// Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. + /// + /// Secrets can be stored in an Azure Key Vault or any other secret store. If the + /// secret is stored in an Azure Key Vault, the value should be the secret + /// identifier and the type should be AKV_SECRET_URI. If the secret is stored + /// elsewhere, the secret value should be provided directly and the type should be + /// SECRET_VALUE. + /// + /// Certificates metadata. + /// Environment variables which are defined as a set of <name,value> pairs. + /// The load test configuration. + /// Id of the test run to be marked as baseline to view trends of client-side metrics from recent test runs. + /// The input artifacts for the test. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The test description. + /// Display name of a test. + /// Subnet ID on which the load test instances should run. + /// Kind of test. + /// Inject load test engines without deploying public IP for outbound access. + /// Type of the managed identity referencing the Key vault. + /// Resource Id of the managed identity referencing the Key vault. + /// Type of the managed identity referencing the metrics. + /// Resource Id of the managed identity referencing the metrics. + /// Type of the managed identity built in load test engines. + /// Resource Ids of the managed identity built in to load test engines. Required if engineBuiltInIdentityType is UserAssigned. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// A new instance for mocking. + public static LoadTest LoadTest(PassFailCriteria passFailCriteria = null, AutoStopCriteria autoStopCriteria = null, IDictionary secrets = null, TestCertificate certificate = null, IDictionary environmentVariables = null, LoadTestConfiguration loadTestConfiguration = null, string baselineTestRunId = null, TestInputArtifacts inputArtifacts = null, string testId = null, string description = null, string displayName = null, string subnetId = null, LoadTestKind? kind = null, bool? publicIpDisabled = null, string keyvaultReferenceIdentityType = null, string keyvaultReferenceIdentityId = null, LoadTestingManagedIdentityType? metricsReferenceIdentityType = null, string metricsReferenceIdentityId = null, LoadTestingManagedIdentityType? engineBuiltInIdentityType = null, IEnumerable engineBuiltInIdentityIds = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + secrets ??= new Dictionary(); + environmentVariables ??= new Dictionary(); + engineBuiltInIdentityIds ??= new List(); + + return new LoadTest( + passFailCriteria, + autoStopCriteria, + secrets, + certificate, + environmentVariables, + loadTestConfiguration, + baselineTestRunId, + inputArtifacts, + testId, + description, + displayName, + subnetId, + kind, + publicIpDisabled, + keyvaultReferenceIdentityType, + keyvaultReferenceIdentityId, + metricsReferenceIdentityType, + metricsReferenceIdentityId, + engineBuiltInIdentityType, + engineBuiltInIdentityIds?.ToList(), + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The client metric on which the criteria should be applied. + /// + /// The aggregation function to be applied on the client metric. Allowed functions + /// - ‘percentage’ - for error metric , ‘avg’, percentiles like ‘p50’, ‘p90’, & so on, ‘min’, + /// ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, + /// ‘count’ - for requests + /// + /// The comparison operator. Supported types ‘>’, ‘<’. + /// Request name for which the Pass fail criteria has to be applied. + /// + /// The value to compare with the client metric. Allowed values - ‘error : [0.0 , + /// 100.0] unit- % ’, response_time_ms and latency : any integer value unit- ms. + /// + /// Action taken after the threshold is met. Default is ‘continue’. + /// The actual value of the client metric for the test run. + /// Outcome of the test run. + /// A new instance for mocking. + public static PassFailMetric PassFailMetric(PfMetrics? clientMetric = null, PassFailAggregationFunction? aggregate = null, string condition = null, string requestName = null, double? value = null, PassFailAction? action = null, double? actualValue = null, PassFailResult? result = null) + { + return new PassFailMetric( + clientMetric, + aggregate, + condition, + requestName, + value, + action, + actualValue, + result, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The resource id of the resource emitting the metric. + /// The server metric namespace. + /// The server metric name. + /// Aggregation Type. + /// The comparison operator. Supported types ‘>’, ‘<’. + /// The value to compare with the server metric. + /// Action taken after the threshold is met. Default is ‘continue’. + /// The actual value of the server metric. + /// Outcome of the test run. + /// A new instance for mocking. + public static PassFailServerMetric PassFailServerMetric(ResourceIdentifier resourceId = null, string metricNamespace = null, string metricName = null, string aggregation = null, string condition = null, double value = default, PassFailAction? action = null, double? actualValue = null, PassFailResult? result = null) + { + return new PassFailServerMetric( + resourceId, + metricNamespace, + metricName, + aggregation, + condition, + value, + action, + actualValue, + result, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The load test YAML file that contains the the test configuration. + /// The test script file for the test run. + /// The user properties file. + /// The zip file with all input artifacts. + /// The config json file for url based test. + /// Additional supported files for the test run. + /// A new instance for mocking. + public static TestInputArtifacts TestInputArtifacts(TestFileInfo configFileInfo = null, TestFileInfo testScriptFileInfo = null, TestFileInfo userPropertyFileInfo = null, TestFileInfo inputArtifactsZipFileInfo = null, TestFileInfo urlTestConfigFileInfo = null, IEnumerable additionalFileInfo = null) + { + additionalFileInfo ??= new List(); + + return new TestInputArtifacts( + configFileInfo, + testScriptFileInfo, + userPropertyFileInfo, + inputArtifactsZipFileInfo, + urlTestConfigFileInfo, + additionalFileInfo?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Name of the file. + /// File URL. + /// File type. + /// Expiry time of the file (RFC 3339 literal format). + /// Validation status of the file. + /// Validation failure error details. + /// A new instance for mocking. + public static TestFileInfo TestFileInfo(string fileName = null, Uri uri = null, LoadTestingFileType? fileType = null, DateTimeOffset? expiresOn = null, FileValidationStatus? validationStatus = null, string validationFailureDetails = null) + { + return new TestFileInfo( + fileName, + uri, + fileType, + expiresOn, + validationStatus, + validationFailureDetails, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// Azure resource collection { resource id (fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + /// : resource object } + /// + /// Test identifier. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// A new instance for mocking. + public static TestAppComponents TestAppComponents(IDictionary components = null, string testId = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + components ??= new Dictionary(); + + return new TestAppComponents( + components, + testId, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + /// Azure resource name, required while creating the app component. + /// Azure resource type, required while creating the app component. + /// Azure resource display name. + /// Resource group name of the Azure resource. + /// Subscription Id of the Azure resource. + /// Kind of Azure resource type. + /// A new instance for mocking. + public static LoadTestingAppComponent LoadTestingAppComponent(ResourceIdentifier resourceId = null, string resourceName = null, string resourceType = null, string displayName = null, string resourceGroup = null, string subscriptionId = null, string kind = null) + { + return new LoadTestingAppComponent( + resourceId, + resourceName, + resourceType, + displayName, + resourceGroup, + subscriptionId, + kind, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Test identifier. + /// + /// Azure resource metrics collection {metric id : metrics object} (Refer : + /// https://learn.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition + /// for metric id). + /// + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// A new instance for mocking. + public static TestServerMetricsConfiguration TestServerMetricsConfiguration(string testId = null, IDictionary metrics = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + metrics ??= new Dictionary(); + + return new TestServerMetricsConfiguration( + testId, + metrics, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Unique name for metric. + /// Azure resource id. + /// Metric name space. + /// Metric description. + /// The invariant value of metric name. + /// Metric aggregation. + /// Metric unit. + /// Azure resource type. + /// A new instance for mocking. + public static ResourceMetric ResourceMetric(string id = null, ResourceIdentifier resourceId = null, string metricNamespace = null, string displayDescription = null, string name = null, string aggregation = null, string unit = null, string resourceType = null) + { + return new ResourceMetric( + id, + resourceId, + metricNamespace, + displayDescription, + name, + aggregation, + unit, + resourceType, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Display name of the test profile. + /// Description for the test profile. + /// Associated test ID for the test profile. This property is required for creating a Test Profile and it's not allowed to be updated. + /// Target resource ID on which the test profile is created. This property is required for creating a Test Profile and it's not allowed to be updated. + /// + /// Configurations of the target resource on which testing would be done. + /// 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 . + /// + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// A new instance for mocking. + public static TestProfile TestProfile(string testProfileId = null, string displayName = null, string description = null, string testId = null, ResourceIdentifier targetResourceId = null, TargetResourceConfigurations targetResourceConfigurations = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + return new TestProfile( + testProfileId, + displayName, + description, + testId, + targetResourceId, + targetResourceConfigurations, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The unique identifier of the trigger. + /// The name of the trigger. + /// The description of the trigger. + /// The type of the trigger. + /// The current state of the trigger. + /// Details of current state of the trigger. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// A new instance for mocking. + public static Trigger Trigger(string triggerId = null, string displayName = null, string description = null, string kind = null, TriggerState? state = null, StateDetails stateDetails = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + return new UnknownTrigger( + triggerId, + displayName, + description, + kind == null ? default : new TriggerType(kind), + state, + stateDetails, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The error message if the trigger is in disabled state. + /// A new instance for mocking. + public static StateDetails StateDetails(string message = null) + { + return new StateDetails(message, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The unique identifier of the trigger. + /// The name of the trigger. + /// The description of the trigger. + /// The current state of the trigger. + /// Details of current state of the trigger. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// The test id of test to be triggered by this schedule trigger. Currently only one test is supported for a trigger. + /// Start date time of the trigger in UTC timezone. (RFC 3339 literal format). + /// + /// + /// Recurrence details of the trigger. Null if schedule is not recurring. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , and . + /// + /// A new instance for mocking. + public static ScheduleTestsTrigger ScheduleTestsTrigger(string triggerId = null, string displayName = null, string description = null, TriggerState? state = null, StateDetails stateDetails = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null, IEnumerable testIds = null, DateTimeOffset? startDateTime = null, RecurrenceStatus recurrenceStatus = null, Recurrence recurrence = null) + { + testIds ??= new List(); + + return new ScheduleTestsTrigger( + triggerId, + displayName, + description, + TriggerType.ScheduleTestsTrigger, + state, + stateDetails, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null, + testIds?.ToList(), + startDateTime, + recurrenceStatus, + recurrence); + } + + /// Initializes a new instance of . + /// The number of occurrences remaining for the trigger. Null if recurrence end has end date instead of number of occurrences. + /// The next three execution times of the trigger. (RFC 3339 literal format). + /// A new instance for mocking. + public static RecurrenceStatus RecurrenceStatus(int? remainingOccurrences = null, IEnumerable nextScheduledDateTimes = null) + { + nextScheduledDateTimes ??= new List(); + + return new RecurrenceStatus(remainingOccurrences, nextScheduledDateTimes?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The unique identifier of the notification rule. + /// The name of the notification rule. + /// The action groups to notify. + /// The scope of the notification rule. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// A new instance for mocking. + public static NotificationRule NotificationRule(string notificationRuleId = null, string displayName = null, IEnumerable actionGroupIds = null, string scope = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + actionGroupIds ??= new List(); + + return new UnknownNotificationRule( + notificationRuleId, + displayName, + actionGroupIds?.ToList(), + scope == null ? default : new NotificationScopeType(scope), + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The unique identifier of the notification rule. + /// The name of the notification rule. + /// The action groups to notify. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// The test ids to include. If not provided, notification will be sent for all testIds. + /// + /// The event to receive notifications for along with filtering conditions. + /// Key is a user-assigned identifier for the event filter. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , and . + /// + /// A new instance for mocking. + public static TestsNotificationRule TestsNotificationRule(string notificationRuleId = null, string displayName = null, IEnumerable actionGroupIds = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null, IEnumerable testIds = null, IDictionary eventFilters = null) + { + actionGroupIds ??= new List(); + testIds ??= new List(); + eventFilters ??= new Dictionary(); + + return new TestsNotificationRule( + notificationRuleId, + displayName, + actionGroupIds?.ToList(), + NotificationScopeType.Tests, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null, + testIds?.ToList(), + eventFilters); + } + + /// Initializes a new instance of . + /// The state of the operation. + /// The kind of the operation. + /// Error object that describes the error when status is "Failed". + /// The unique ID of the operation. + /// A new instance for mocking. + public static OperationStatus OperationStatus(OperationState status = default, OperationKind kind = default, ResponseError error = null, string id = null) + { + return new OperationStatus(status, kind, error, id, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Pass fail criteria for a test. + /// Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. + /// + /// Secrets can be stored in an Azure Key Vault or any other secret store. If the + /// secret is stored in an Azure Key Vault, the value should be the secret + /// identifier and the type should be AKV_SECRET_URI. If the secret is stored + /// elsewhere, the secret value should be provided directly and the type should be + /// SECRET_VALUE. + /// + /// Certificates metadata. + /// Environment variables which are defined as a set of <name,value> pairs. + /// Error details if there is any failure in load test run. + /// + /// Test run statistics. Key is the sampler name and value is the set of statistics for performance metrics like response time, throughput, etc. from the load test run. + /// The sampler name is the same as the name mentioned in the test script. + /// Sampler name "Total" represents the aggregated statistics of all the samplers. + /// + /// + /// Regional statistics. Key is the Azure region name and value is the test run statistics. + /// The region name should of format accepted by ARM, and should be a region supported by Azure Load Testing. For example, East US should be passed as "eastus". + /// The region name must match one of the strings in the "Name" column returned from running the "az account list-locations -o table" Azure CLI command. + /// + /// The load test configuration. + /// Collection of test run artifacts. + /// Test result for pass/Fail criteria used during the test run. + /// Number of virtual users, for which test has been run. + /// Display name of a testRun. + /// Associated test Id. + /// The test run description. + /// The test run status. + /// The test run start DateTime(RFC 3339 literal format). + /// The test run end DateTime(RFC 3339 literal format). + /// Test run initiated time. + /// Portal url. + /// Test run duration in milliseconds. + /// Virtual user hours consumed by the test run. + /// Subnet ID on which the load test instances should run. + /// Type of test. + /// Request data collection level for test run. + /// Enable or disable debug level logging. True if debug logs are enabled for the test run. False otherwise. + /// Inject load test engines without deploying public IP for outbound access. + /// The type of the entity that created the test run. (E.x. User, ScheduleTrigger, etc). + /// The URI pointing to the entity that created the test run. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// A new instance for mocking. + public static LoadTestRun LoadTestRun(string testRunId = null, PassFailCriteria passFailCriteria = null, AutoStopCriteria autoStopCriteria = null, IDictionary secrets = null, TestCertificate certificate = null, IDictionary environmentVariables = null, IEnumerable errorDetails = null, IReadOnlyDictionary testRunStatistics = null, IReadOnlyDictionary regionalStatistics = null, LoadTestConfiguration loadTestConfiguration = null, TestRunArtifacts testArtifacts = null, PassFailTestResult? testResult = null, int? virtualUsers = null, string displayName = null, string testId = null, string description = null, TestRunStatus? status = null, DateTimeOffset? startDateTime = null, DateTimeOffset? endDateTime = null, DateTimeOffset? executedDateTime = null, Uri portalUri = null, long? duration = null, double? virtualUserHours = null, string subnetId = null, LoadTestKind? kind = null, RequestDataLevel? requestDataLevel = null, bool? debugLogsEnabled = null, bool? publicIpDisabled = null, CreatedByType? createdByType = null, Uri createdByUri = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + secrets ??= new Dictionary(); + environmentVariables ??= new Dictionary(); + errorDetails ??= new List(); + testRunStatistics ??= new Dictionary(); + regionalStatistics ??= new Dictionary(); + + return new LoadTestRun( + testRunId, + passFailCriteria, + autoStopCriteria, + secrets, + certificate, + environmentVariables, + errorDetails?.ToList(), + testRunStatistics, + regionalStatistics, + loadTestConfiguration, + testArtifacts, + testResult, + virtualUsers, + displayName, + testId, + description, + status, + startDateTime, + endDateTime, + executedDateTime, + portalUri, + duration, + virtualUserHours, + subnetId, + kind, + requestDataLevel, + debugLogsEnabled, + publicIpDisabled, + createdByType, + createdByUri, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Error details in case test run was not successfully run. + /// A new instance for mocking. + public static ErrorDetails ErrorDetails(string message = null) + { + return new ErrorDetails(message, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Transaction name. + /// Sampler count. + /// Error count. + /// Error percentage. + /// Mean response time. + /// Median response time. + /// Max response time. + /// Minimum response time. + /// 90 percentile response time. + /// 95 percentile response time. + /// 99 percentile response time. + /// 75 percentile response time. + /// 96 percentile response time. + /// 97 percentile response time. + /// 98 percentile response time. + /// 99.9 percentile response time. + /// 99.99 percentile response time. + /// Throughput. + /// Received network bytes. + /// Send network bytes. + /// A new instance for mocking. + public static TestRunStatistics TestRunStatistics(string transaction = null, double? sampleCount = null, double? errorCount = null, double? errorPercentage = null, double? meanResponseTime = null, double? medianResponseTime = null, double? maxResponseTime = null, double? minResponseTime = null, double? percentile90ResponseTime = null, double? percentile95ResponseTime = null, double? percentile99ResponseTime = null, double? percentile75ResponseTime = null, double? percentile96ResponseTime = null, double? percentile97ResponseTime = null, double? percentile98ResponseTime = null, double? percentile999ResponseTime = null, double? percentile9999ResponseTime = null, double? throughput = null, double? receivedKBytesPerSec = null, double? sentKBytesPerSec = null) + { + return new TestRunStatistics( + transaction, + sampleCount, + errorCount, + errorPercentage, + meanResponseTime, + medianResponseTime, + maxResponseTime, + minResponseTime, + percentile90ResponseTime, + percentile95ResponseTime, + percentile99ResponseTime, + percentile75ResponseTime, + percentile96ResponseTime, + percentile97ResponseTime, + percentile98ResponseTime, + percentile999ResponseTime, + percentile9999ResponseTime, + throughput, + receivedKBytesPerSec, + sentKBytesPerSec, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The input artifacts for the test run. + /// The output artifacts for the test run. + /// A new instance for mocking. + public static TestRunArtifacts TestRunArtifacts(TestRunInputArtifacts inputArtifacts = null, TestRunOutputArtifacts outputArtifacts = null) + { + return new TestRunArtifacts(inputArtifacts, outputArtifacts, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The load test YAML file that contains the the test configuration. + /// The test script file for the test run. + /// The user properties file. + /// The zip file for all input artifacts. + /// The config json file for url based test. + /// Additional supported files for the test run. + /// A new instance for mocking. + public static TestRunInputArtifacts TestRunInputArtifacts(TestRunFileInfo configFileInfo = null, TestRunFileInfo testScriptFileInfo = null, TestRunFileInfo userPropertyFileInfo = null, TestRunFileInfo inputArtifactsZipFileInfo = null, TestRunFileInfo urlTestConfigFileInfo = null, IEnumerable additionalFileInfo = null) + { + additionalFileInfo ??= new List(); + + return new TestRunInputArtifacts( + configFileInfo, + testScriptFileInfo, + userPropertyFileInfo, + inputArtifactsZipFileInfo, + urlTestConfigFileInfo, + additionalFileInfo?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Name of the file. + /// File URL. + /// File type. + /// Expiry time of the file (RFC 3339 literal format). + /// Validation status of the file. + /// Validation failure error details. + /// A new instance for mocking. + public static TestRunFileInfo TestRunFileInfo(string fileName = null, Uri uri = null, LoadTestingFileType? fileType = null, DateTimeOffset? expiresOn = null, FileValidationStatus? validationStatus = null, string validationFailureDetails = null) + { + return new TestRunFileInfo( + fileName, + uri, + fileType, + expiresOn, + validationStatus, + validationFailureDetails, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The test run results file. + /// The test run report with metrics. + /// The container for test run artifacts. + /// The report file for the test run. + /// A new instance for mocking. + public static TestRunOutputArtifacts TestRunOutputArtifacts(TestRunFileInfo resultFileInfo = null, TestRunFileInfo logsFileInfo = null, ArtifactsContainerInfo artifactsContainerInfo = null, TestRunFileInfo reportFileInfo = null) + { + return new TestRunOutputArtifacts(resultFileInfo, logsFileInfo, artifactsContainerInfo, reportFileInfo, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// This is a SAS URI to an Azure Storage Container that contains the test run artifacts. + /// Expiry time of the container (RFC 3339 literal format). + /// A new instance for mocking. + public static ArtifactsContainerInfo ArtifactsContainerInfo(Uri uri = null, DateTimeOffset? expiresOn = null) + { + return new ArtifactsContainerInfo(uri, expiresOn, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// Azure resource collection { resource id (fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + /// : resource object } + /// + /// Test run identifier. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// A new instance for mocking. + public static TestRunAppComponents TestRunAppComponents(IDictionary components = null, string testRunId = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + components ??= new Dictionary(); + + return new TestRunAppComponents( + components, + testRunId, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Test run identifier. + /// + /// Azure resource metrics collection {metric id : metrics object} (Refer : + /// https://learn.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition + /// for metric id). + /// + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// A new instance for mocking. + public static TestRunServerMetricsConfiguration TestRunServerMetricsConfiguration(string testRunId = null, IDictionary metrics = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + metrics ??= new Dictionary(); + + return new TestRunServerMetricsConfiguration( + testRunId, + metrics, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// the values for the metric definitions. + /// A new instance for mocking. + public static MetricDefinitions MetricDefinitions(IEnumerable value = null) + { + value ??= new List(); + + return new MetricDefinitions(value?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// List of dimensions. + /// The metric description. + /// The metric name. + /// The namespace the metric belongs to. + /// The primary aggregation type value defining how to use the values for display. + /// The collection of what all aggregation types are supported. + /// The unit of the metric. + /// + /// Metric availability specifies the time grain (aggregation interval or + /// frequency). + /// + /// A new instance for mocking. + public static MetricDefinition MetricDefinition(IEnumerable dimensions = null, string description = null, string name = null, string @namespace = null, AggregationType? primaryAggregationType = null, IEnumerable supportedAggregationTypes = null, MetricUnit? unit = null, IEnumerable metricAvailabilities = null) + { + dimensions ??= new List(); + supportedAggregationTypes ??= new List(); + metricAvailabilities ??= new List(); + + return new MetricDefinition( + dimensions?.ToList(), + description, + name, + @namespace, + primaryAggregationType, + supportedAggregationTypes?.ToList(), + unit, + metricAvailabilities?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The description. + /// The name. + /// A new instance for mocking. + public static NameAndDescription NameAndDescription(string description = null, string name = null) + { + return new NameAndDescription(description, name, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// The time grain specifies the aggregation interval for the metric. Expressed as + /// a duration 'PT1M', 'PT1H', etc. + /// + /// A new instance for mocking. + public static MetricAvailability MetricAvailability(TimeGrain? timeGrain = null) + { + return new MetricAvailability(timeGrain, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The values for the metric namespaces. + /// A new instance for mocking. + public static MetricNamespaces MetricNamespaces(IEnumerable value = null) + { + value ??= new List(); + + return new MetricNamespaces(value?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The namespace description. + /// The metric namespace name. + /// A new instance for mocking. + public static MetricNamespace MetricNamespace(string description = null, string name = null) + { + return new MetricNamespace(description, name, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// An array of data points representing the metric values. + /// The dimension values. + /// A new instance for mocking. + public static TimeSeriesElement TimeSeriesElement(IEnumerable data = null, IEnumerable dimensionValues = null) + { + data ??= new List(); + dimensionValues ??= new List(); + + return new TimeSeriesElement(data?.ToList(), dimensionValues?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The timestamp for the metric value in RFC 3339 format. + /// The metric value. + /// A new instance for mocking. + public static MetricValue MetricValue(DateTimeOffset? timestamp = null, double? value = null) + { + return new MetricValue(timestamp, value, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The name of the dimension. + /// The value of the dimension. + /// A new instance for mocking. + public static DimensionValue DimensionValue(string name = null, string value = null) + { + return new DimensionValue(name, value, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Display name for the test profile run. + /// The test profile run description. + /// Associated test profile ID for the test profile run. This is required to create a test profile run and can't be updated. + /// Target resource ID on which the test profile run is created. + /// + /// Configurations of the target resource on which the test profile ran. + /// 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 . + /// + /// The test profile run status. + /// Error details if there is any failure in test profile run. These errors are specific to the Test Profile Run. + /// The test profile run start DateTime(RFC 3339 literal format). + /// The test profile run end DateTime(RFC 3339 literal format). + /// Test profile run duration in seconds. + /// + /// Details of the test runs ran as part of the test profile run. + /// Key is the testRunId of the corresponding testRun. + /// + /// Recommendations provided based on a successful test profile run. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// A new instance for mocking. + public static TestProfileRun TestProfileRun(string testProfileRunId = null, string displayName = null, string description = null, string testProfileId = null, ResourceIdentifier targetResourceId = null, TargetResourceConfigurations targetResourceConfigurations = null, TestProfileRunStatus? status = null, IEnumerable errorDetails = null, DateTimeOffset? startDateTime = null, DateTimeOffset? endDateTime = null, long? durationInSeconds = null, IReadOnlyDictionary testRunDetails = null, IEnumerable recommendations = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + errorDetails ??= new List(); + testRunDetails ??= new Dictionary(); + recommendations ??= new List(); + + return new TestProfileRun( + testProfileRunId, + displayName, + description, + testProfileId, + targetResourceId, + targetResourceConfigurations, + status, + errorDetails?.ToList(), + startDateTime, + endDateTime, + durationInSeconds, + testRunDetails, + recommendations?.ToList(), + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Status of the test run. + /// ID of the configuration on which the test ran. + /// Key value pair of extra properties associated with the test run. + /// A new instance for mocking. + public static TestRunDetail TestRunDetail(TestRunStatus status = default, string configurationId = null, IReadOnlyDictionary properties = null) + { + properties ??= new Dictionary(); + + return new TestRunDetail(status, configurationId, properties, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Category of the recommendation. + /// List of configurations IDs for which the recommendation is applicable. These are a subset of the provided target resource configurations. + /// A new instance for mocking. + public static TestProfileRunRecommendation TestProfileRunRecommendation(RecommendationCategory category = default, IEnumerable configurations = null) + { + configurations ??= new List(); + + return new TestProfileRunRecommendation(category, configurations?.ToList(), serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DimensionFilter.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DimensionFilter.Serialization.cs new file mode 100644 index 000000000000..08a6ff012082 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DimensionFilter.Serialization.cs @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class DimensionFilter : 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(DimensionFilter)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsCollectionDefined(Values)) + { + writer.WritePropertyName("values"u8); + writer.WriteStartArray(); + foreach (var item in Values) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + DimensionFilter 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(DimensionFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDimensionFilter(document.RootElement, options); + } + + internal static DimensionFilter DeserializeDimensionFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + IList values = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("values"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + values = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DimensionFilter(name, values ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DimensionFilter)} does not support writing '{options.Format}' format."); + } + } + + DimensionFilter 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 DeserializeDimensionFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DimensionFilter)} 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 DimensionFilter FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDimensionFilter(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/DimensionFilter.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DimensionFilter.cs new file mode 100644 index 000000000000..51ae24c5f29d --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DimensionFilter.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Dimension name and values to filter. + public partial class DimensionFilter + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public DimensionFilter() + { + Values = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The dimension name. + /// The dimension values. Maximum values can be 20. + /// Keeps track of any properties unknown to the library. + internal DimensionFilter(string name, IList values, IDictionary serializedAdditionalRawData) + { + Name = name; + Values = values; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The dimension name. + public string Name { get; set; } + /// The dimension values. Maximum values can be 20. + public IList Values { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DimensionValue.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DimensionValue.Serialization.cs new file mode 100644 index 000000000000..a4d891c69967 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DimensionValue.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.Developer.LoadTesting +{ + public partial class DimensionValue : 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(DimensionValue)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + DimensionValue 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(DimensionValue)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDimensionValue(document.RootElement, options); + } + + internal static DimensionValue DeserializeDimensionValue(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("value"u8)) + { + value = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DimensionValue(name, value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DimensionValue)} does not support writing '{options.Format}' format."); + } + } + + DimensionValue 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 DeserializeDimensionValue(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DimensionValue)} 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 DimensionValue FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDimensionValue(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/DimensionValue.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DimensionValue.cs new file mode 100644 index 000000000000..84f36f89f44e --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DimensionValue.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.Developer.LoadTesting +{ + /// Represents a metric dimension value. + public partial class DimensionValue + { + /// + /// 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 DimensionValue() + { + } + + /// Initializes a new instance of . + /// The name of the dimension. + /// The value of the dimension. + /// Keeps track of any properties unknown to the library. + internal DimensionValue(string name, string value, IDictionary serializedAdditionalRawData) + { + Name = name; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The name of the dimension. + public string Name { get; } + /// The value of the dimension. + public string Value { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ErrorDetails.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ErrorDetails.Serialization.cs new file mode 100644 index 000000000000..d2016b9b5ab4 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ErrorDetails.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class ErrorDetails : 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(ErrorDetails)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Message)) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + 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 + } + } + } + + ErrorDetails 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(ErrorDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeErrorDetails(document.RootElement, options); + } + + internal static ErrorDetails DeserializeErrorDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string message = 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 (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ErrorDetails(message, 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(ErrorDetails)} does not support writing '{options.Format}' format."); + } + } + + ErrorDetails 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 DeserializeErrorDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ErrorDetails)} 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 ErrorDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeErrorDetails(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/ErrorDetails.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ErrorDetails.cs new file mode 100644 index 000000000000..42c16951cb7c --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ErrorDetails.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Error details if there is any failure in load test run. + public partial class ErrorDetails + { + /// + /// 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 ErrorDetails() + { + } + + /// Initializes a new instance of . + /// Error details in case test run was not successfully run. + /// Keeps track of any properties unknown to the library. + internal ErrorDetails(string message, IDictionary serializedAdditionalRawData) + { + Message = message; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Error details in case test run was not successfully run. + public string Message { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/FileValidationStatus.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/FileValidationStatus.cs new file mode 100644 index 000000000000..93393256bc43 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/FileValidationStatus.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// File status. + public readonly partial struct FileValidationStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public FileValidationStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NotValidatedValue = "NOT_VALIDATED"; + private const string ValidationSuccessValue = "VALIDATION_SUCCESS"; + private const string ValidationFailureValue = "VALIDATION_FAILURE"; + private const string ValidationInitiatedValue = "VALIDATION_INITIATED"; + private const string ValidationNotRequiredValue = "VALIDATION_NOT_REQUIRED"; + + /// File is not validated. + public static FileValidationStatus NotValidated { get; } = new FileValidationStatus(NotValidatedValue); + /// File is validated. + public static FileValidationStatus ValidationSuccess { get; } = new FileValidationStatus(ValidationSuccessValue); + /// File validation is failed. + public static FileValidationStatus ValidationFailure { get; } = new FileValidationStatus(ValidationFailureValue); + /// File validation is in progress. + public static FileValidationStatus ValidationInitiated { get; } = new FileValidationStatus(ValidationInitiatedValue); + /// Validation is not required. + public static FileValidationStatus ValidationNotRequired { get; } = new FileValidationStatus(ValidationNotRequiredValue); + /// Determines if two values are the same. + public static bool operator ==(FileValidationStatus left, FileValidationStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(FileValidationStatus left, FileValidationStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator FileValidationStatus(string value) => new FileValidationStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FileValidationStatus other && Equals(other); + /// + public bool Equals(FileValidationStatus 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/Frequency.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Frequency.cs new file mode 100644 index 000000000000..2c71e6f486c7 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Frequency.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Frequency of recurrence for a trigger. + internal readonly partial struct Frequency : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public Frequency(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string CronValue = "Cron"; + private const string HourlyValue = "Hourly"; + private const string DailyValue = "Daily"; + private const string WeeklyValue = "Weekly"; + private const string MonthlyByDaysValue = "MonthlyByDays"; + private const string MonthlyByDatesValue = "MonthlyByDates"; + + /// Recurrence defined by a cron expression. + public static Frequency Cron { get; } = new Frequency(CronValue); + /// Recurrence defined on an hourly basis, as specified by HourlyRecurrence. + public static Frequency Hourly { get; } = new Frequency(HourlyValue); + /// Recurrence defined on a daily basis, as specified by DailyRecurrence. + public static Frequency Daily { get; } = new Frequency(DailyValue); + /// Recurrence defined on a weekly basis, as specified by WeeklyRecurrence. + public static Frequency Weekly { get; } = new Frequency(WeeklyValue); + /// Recurrence defined monthly on specific days, as specified by MonthlyRecurrenceByWeekDays. + public static Frequency MonthlyByDays { get; } = new Frequency(MonthlyByDaysValue); + /// Recurrence defined monthly on specific dates, as specified by MonthlyRecurrenceByDates. + public static Frequency MonthlyByDates { get; } = new Frequency(MonthlyByDatesValue); + /// Determines if two values are the same. + public static bool operator ==(Frequency left, Frequency right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(Frequency left, Frequency right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator Frequency(string value) => new Frequency(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is Frequency other && Equals(other); + /// + public bool Equals(Frequency 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionResourceConfiguration.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionResourceConfiguration.Serialization.cs new file mode 100644 index 000000000000..70955cafaa59 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionResourceConfiguration.Serialization.cs @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class FunctionFlexConsumptionResourceConfiguration : 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(FunctionFlexConsumptionResourceConfiguration)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("instanceMemoryMB"u8); + writer.WriteNumberValue(InstanceMemoryMB); + if (Optional.IsDefined(HttpConcurrency)) + { + writer.WritePropertyName("httpConcurrency"u8); + writer.WriteNumberValue(HttpConcurrency.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + FunctionFlexConsumptionResourceConfiguration 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(FunctionFlexConsumptionResourceConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFunctionFlexConsumptionResourceConfiguration(document.RootElement, options); + } + + internal static FunctionFlexConsumptionResourceConfiguration DeserializeFunctionFlexConsumptionResourceConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + long instanceMemoryMB = default; + long? httpConcurrency = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("instanceMemoryMB"u8)) + { + instanceMemoryMB = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("httpConcurrency"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + httpConcurrency = property.Value.GetInt64(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FunctionFlexConsumptionResourceConfiguration(instanceMemoryMB, httpConcurrency, 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(FunctionFlexConsumptionResourceConfiguration)} does not support writing '{options.Format}' format."); + } + } + + FunctionFlexConsumptionResourceConfiguration 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 DeserializeFunctionFlexConsumptionResourceConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FunctionFlexConsumptionResourceConfiguration)} 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 FunctionFlexConsumptionResourceConfiguration FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFunctionFlexConsumptionResourceConfiguration(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionResourceConfiguration.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionResourceConfiguration.cs new file mode 100644 index 000000000000..78c4e07ce0de --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionResourceConfiguration.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Resource configuration instance for a Flex Consumption based Azure Function App. + public partial class FunctionFlexConsumptionResourceConfiguration + { + /// + /// 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 . + /// Memory size of the instance. Supported values are 2048, 4096. + public FunctionFlexConsumptionResourceConfiguration(long instanceMemoryMB) + { + InstanceMemoryMB = instanceMemoryMB; + } + + /// Initializes a new instance of . + /// Memory size of the instance. Supported values are 2048, 4096. + /// HTTP Concurrency for the function app. + /// Keeps track of any properties unknown to the library. + internal FunctionFlexConsumptionResourceConfiguration(long instanceMemoryMB, long? httpConcurrency, IDictionary serializedAdditionalRawData) + { + InstanceMemoryMB = instanceMemoryMB; + HttpConcurrency = httpConcurrency; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FunctionFlexConsumptionResourceConfiguration() + { + } + + /// Memory size of the instance. Supported values are 2048, 4096. + public long InstanceMemoryMB { get; set; } + /// HTTP Concurrency for the function app. + public long? HttpConcurrency { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionTargetResourceConfigurations.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionTargetResourceConfigurations.Serialization.cs new file mode 100644 index 000000000000..090bcda9c39f --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionTargetResourceConfigurations.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class FunctionFlexConsumptionTargetResourceConfigurations : 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(FunctionFlexConsumptionTargetResourceConfigurations)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsCollectionDefined(Configurations)) + { + writer.WritePropertyName("configurations"u8); + writer.WriteStartObject(); + foreach (var item in Configurations) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + } + + FunctionFlexConsumptionTargetResourceConfigurations 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(FunctionFlexConsumptionTargetResourceConfigurations)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFunctionFlexConsumptionTargetResourceConfigurations(document.RootElement, options); + } + + internal static FunctionFlexConsumptionTargetResourceConfigurations DeserializeFunctionFlexConsumptionTargetResourceConfigurations(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary configurations = default; + ResourceKind kind = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("configurations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, FunctionFlexConsumptionResourceConfiguration.DeserializeFunctionFlexConsumptionResourceConfiguration(property0.Value, options)); + } + configurations = dictionary; + continue; + } + if (property.NameEquals("kind"u8)) + { + kind = new ResourceKind(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FunctionFlexConsumptionTargetResourceConfigurations(kind, serializedAdditionalRawData, configurations ?? new ChangeTrackingDictionary()); + } + + 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(FunctionFlexConsumptionTargetResourceConfigurations)} does not support writing '{options.Format}' format."); + } + } + + FunctionFlexConsumptionTargetResourceConfigurations 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 DeserializeFunctionFlexConsumptionTargetResourceConfigurations(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FunctionFlexConsumptionTargetResourceConfigurations)} 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 FunctionFlexConsumptionTargetResourceConfigurations FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFunctionFlexConsumptionTargetResourceConfigurations(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionTargetResourceConfigurations.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionTargetResourceConfigurations.cs new file mode 100644 index 000000000000..3325be60e099 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionTargetResourceConfigurations.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Configurations for a Function App using Flex Consumption Plan. + public partial class FunctionFlexConsumptionTargetResourceConfigurations : TargetResourceConfigurations + { + /// Initializes a new instance of . + public FunctionFlexConsumptionTargetResourceConfigurations() + { + Kind = ResourceKind.FunctionsFlexConsumption; + Configurations = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Kind of the resource for which the configurations apply. + /// Keeps track of any properties unknown to the library. + /// A map of configurations for a Function app using Flex Consumption Plan. + internal FunctionFlexConsumptionTargetResourceConfigurations(ResourceKind kind, IDictionary serializedAdditionalRawData, IDictionary configurations) : base(kind, serializedAdditionalRawData) + { + Configurations = configurations; + } + + /// A map of configurations for a Function app using Flex Consumption Plan. + public IDictionary Configurations { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/HourlyRecurrence.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/HourlyRecurrence.Serialization.cs new file mode 100644 index 000000000000..5ebb5b01a063 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/HourlyRecurrence.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class HourlyRecurrence : 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(HourlyRecurrence)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("interval"u8); + writer.WriteNumberValue(Interval); + } + + HourlyRecurrence 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(HourlyRecurrence)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHourlyRecurrence(document.RootElement, options); + } + + internal static HourlyRecurrence DeserializeHourlyRecurrence(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int interval = default; + Frequency frequency = default; + RecurrenceEnd recurrenceEnd = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("interval"u8)) + { + interval = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("frequency"u8)) + { + frequency = new Frequency(property.Value.GetString()); + continue; + } + if (property.NameEquals("recurrenceEnd"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new HourlyRecurrence(frequency, recurrenceEnd, serializedAdditionalRawData, interval); + } + + 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(HourlyRecurrence)} does not support writing '{options.Format}' format."); + } + } + + HourlyRecurrence 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 DeserializeHourlyRecurrence(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HourlyRecurrence)} 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 HourlyRecurrence FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeHourlyRecurrence(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/HourlyRecurrence.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/HourlyRecurrence.cs new file mode 100644 index 000000000000..642b00b8c586 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/HourlyRecurrence.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Recurrence model when frequency is set as Hourly. + public partial class HourlyRecurrence : Recurrence + { + /// Initializes a new instance of . + /// The interval at which the recurrence should repeat. It signifies the number of hours between each recurrence. + public HourlyRecurrence(int interval) + { + Frequency = Frequency.Hourly; + Interval = interval; + } + + /// Initializes a new instance of . + /// Frequency of the recurrence. + /// Recurrence end model. You can specify the end either by providing a numberOfOccurrences (which will end the recurrence after the specified number of occurrences) or by providing an endDateTime (which will end the recurrence after the specified date). If neither value is provided, the recurrence will continue until it is manually ended. However, if both values are provided, an error will be thrown. + /// Keeps track of any properties unknown to the library. + /// The interval at which the recurrence should repeat. It signifies the number of hours between each recurrence. + internal HourlyRecurrence(Frequency frequency, RecurrenceEnd recurrenceEnd, IDictionary serializedAdditionalRawData, int interval) : base(frequency, recurrenceEnd, serializedAdditionalRawData) + { + Interval = interval; + } + + /// Initializes a new instance of for deserialization. + internal HourlyRecurrence() + { + } + + /// The interval at which the recurrence should repeat. It signifies the number of hours between each recurrence. + public int Interval { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Argument.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..946929b236ff --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/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.Developer.LoadTesting +{ + 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..9a5316eba10d --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/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.Developer.LoadTesting +{ + 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingList.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..5de833439355 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/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.Developer.LoadTesting +{ + 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..f72f1fe51168 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/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.Developer.LoadTesting +{ + internal static class ModelSerializationExtensions + { + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + var dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + var list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + var text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + { + throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + var value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case IUtf8JsonSerializable serializable: + serializable.Write(writer); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + internal static class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Azure SDK requires it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; + int size = checked(numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ConvertToString(object value, string format = null) => value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when format != null => ToString(b0, format), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when format != null => ToString(dateTime, format), + TimeSpan timeSpan when format != null => ToString(timeSpan, format), + TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Optional.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..248e10182762 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.Developer.LoadTesting +{ + internal static class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + + public static bool IsDefined(string value) + { + return value != null; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..5130928c6e0b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.IO; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + internal class Utf8JsonRequestContent : RequestContent + { + private readonly MemoryStream _stream; + private readonly RequestContent _content; + + public Utf8JsonRequestContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + public Utf8JsonWriter JsonWriter { get; } + + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { + JsonWriter.Flush(); + _content.WriteTo(stream, cancellationToken); + } + + public override bool TryComputeLength(out long length) + { + length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; + return true; + } + + public override void Dispose() + { + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTest.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTest.Serialization.cs new file mode 100644 index 000000000000..50a4e9760e37 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTest.Serialization.cs @@ -0,0 +1,511 @@ +// 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.Developer.LoadTesting +{ + public partial class LoadTest : 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(LoadTest)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(PassFailCriteria)) + { + writer.WritePropertyName("passFailCriteria"u8); + writer.WriteObjectValue(PassFailCriteria, options); + } + if (Optional.IsDefined(AutoStopCriteria)) + { + writer.WritePropertyName("autoStopCriteria"u8); + writer.WriteObjectValue(AutoStopCriteria, options); + } + if (Optional.IsCollectionDefined(Secrets)) + { + writer.WritePropertyName("secrets"u8); + writer.WriteStartObject(); + foreach (var item in Secrets) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Certificate)) + { + writer.WritePropertyName("certificate"u8); + writer.WriteObjectValue(Certificate, options); + } + if (Optional.IsCollectionDefined(EnvironmentVariables)) + { + writer.WritePropertyName("environmentVariables"u8); + writer.WriteStartObject(); + foreach (var item in EnvironmentVariables) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(LoadTestConfiguration)) + { + writer.WritePropertyName("loadTestConfiguration"u8); + writer.WriteObjectValue(LoadTestConfiguration, options); + } + if (Optional.IsDefined(BaselineTestRunId)) + { + writer.WritePropertyName("baselineTestRunId"u8); + writer.WriteStringValue(BaselineTestRunId); + } + if (options.Format != "W" && Optional.IsDefined(InputArtifacts)) + { + writer.WritePropertyName("inputArtifacts"u8); + writer.WriteObjectValue(InputArtifacts, options); + } + if (options.Format != "W") + { + writer.WritePropertyName("testId"u8); + writer.WriteStringValue(TestId); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsDefined(SubnetId)) + { + writer.WritePropertyName("subnetId"u8); + writer.WriteStringValue(SubnetId); + } + if (Optional.IsDefined(Kind)) + { + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.Value.ToString()); + } + if (Optional.IsDefined(PublicIpDisabled)) + { + writer.WritePropertyName("publicIPDisabled"u8); + writer.WriteBooleanValue(PublicIpDisabled.Value); + } + if (Optional.IsDefined(KeyvaultReferenceIdentityType)) + { + writer.WritePropertyName("keyvaultReferenceIdentityType"u8); + writer.WriteStringValue(KeyvaultReferenceIdentityType); + } + if (Optional.IsDefined(KeyvaultReferenceIdentityId)) + { + writer.WritePropertyName("keyvaultReferenceIdentityId"u8); + writer.WriteStringValue(KeyvaultReferenceIdentityId); + } + if (Optional.IsDefined(MetricsReferenceIdentityType)) + { + writer.WritePropertyName("metricsReferenceIdentityType"u8); + writer.WriteStringValue(MetricsReferenceIdentityType.Value.ToString()); + } + if (Optional.IsDefined(MetricsReferenceIdentityId)) + { + writer.WritePropertyName("metricsReferenceIdentityId"u8); + writer.WriteStringValue(MetricsReferenceIdentityId); + } + if (Optional.IsDefined(EngineBuiltInIdentityType)) + { + writer.WritePropertyName("engineBuiltInIdentityType"u8); + writer.WriteStringValue(EngineBuiltInIdentityType.Value.ToString()); + } + if (Optional.IsCollectionDefined(EngineBuiltInIdentityIds)) + { + writer.WritePropertyName("engineBuiltInIdentityIds"u8); + writer.WriteStartArray(); + foreach (var item in EngineBuiltInIdentityIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedDateTime)) + { + writer.WritePropertyName("lastModifiedDateTime"u8); + writer.WriteStringValue(LastModifiedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedBy)) + { + writer.WritePropertyName("lastModifiedBy"u8); + writer.WriteStringValue(LastModifiedBy); + } + 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 + } + } + } + + LoadTest 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(LoadTest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLoadTest(document.RootElement, options); + } + + internal static LoadTest DeserializeLoadTest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + PassFailCriteria passFailCriteria = default; + AutoStopCriteria autoStopCriteria = default; + IDictionary secrets = default; + TestCertificate certificate = default; + IDictionary environmentVariables = default; + LoadTestConfiguration loadTestConfiguration = default; + string baselineTestRunId = default; + TestInputArtifacts inputArtifacts = default; + string testId = default; + string description = default; + string displayName = default; + string subnetId = default; + LoadTestKind? kind = default; + bool? publicIPDisabled = default; + string keyvaultReferenceIdentityType = default; + string keyvaultReferenceIdentityId = default; + LoadTestingManagedIdentityType? metricsReferenceIdentityType = default; + string metricsReferenceIdentityId = default; + LoadTestingManagedIdentityType? engineBuiltInIdentityType = default; + IList engineBuiltInIdentityIds = default; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("passFailCriteria"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + passFailCriteria = PassFailCriteria.DeserializePassFailCriteria(property.Value, options); + continue; + } + if (property.NameEquals("autoStopCriteria"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + autoStopCriteria = AutoStopCriteria.DeserializeAutoStopCriteria(property.Value, options); + continue; + } + if (property.NameEquals("secrets"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, TestSecret.DeserializeTestSecret(property0.Value, options)); + } + secrets = dictionary; + continue; + } + if (property.NameEquals("certificate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + certificate = TestCertificate.DeserializeTestCertificate(property.Value, options); + continue; + } + if (property.NameEquals("environmentVariables"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + environmentVariables = dictionary; + continue; + } + if (property.NameEquals("loadTestConfiguration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + loadTestConfiguration = LoadTestConfiguration.DeserializeLoadTestConfiguration(property.Value, options); + continue; + } + if (property.NameEquals("baselineTestRunId"u8)) + { + baselineTestRunId = property.Value.GetString(); + continue; + } + if (property.NameEquals("inputArtifacts"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + inputArtifacts = TestInputArtifacts.DeserializeTestInputArtifacts(property.Value, options); + continue; + } + if (property.NameEquals("testId"u8)) + { + testId = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("subnetId"u8)) + { + subnetId = property.Value.GetString(); + continue; + } + if (property.NameEquals("kind"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + kind = new LoadTestKind(property.Value.GetString()); + continue; + } + if (property.NameEquals("publicIPDisabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + publicIPDisabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("keyvaultReferenceIdentityType"u8)) + { + keyvaultReferenceIdentityType = property.Value.GetString(); + continue; + } + if (property.NameEquals("keyvaultReferenceIdentityId"u8)) + { + keyvaultReferenceIdentityId = property.Value.GetString(); + continue; + } + if (property.NameEquals("metricsReferenceIdentityType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + metricsReferenceIdentityType = new LoadTestingManagedIdentityType(property.Value.GetString()); + continue; + } + if (property.NameEquals("metricsReferenceIdentityId"u8)) + { + metricsReferenceIdentityId = property.Value.GetString(); + continue; + } + if (property.NameEquals("engineBuiltInIdentityType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + engineBuiltInIdentityType = new LoadTestingManagedIdentityType(property.Value.GetString()); + continue; + } + if (property.NameEquals("engineBuiltInIdentityIds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + engineBuiltInIdentityIds = array; + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new LoadTest( + passFailCriteria, + autoStopCriteria, + secrets ?? new ChangeTrackingDictionary(), + certificate, + environmentVariables ?? new ChangeTrackingDictionary(), + loadTestConfiguration, + baselineTestRunId, + inputArtifacts, + testId, + description, + displayName, + subnetId, + kind, + publicIPDisabled, + keyvaultReferenceIdentityType, + keyvaultReferenceIdentityId, + metricsReferenceIdentityType, + metricsReferenceIdentityId, + engineBuiltInIdentityType, + engineBuiltInIdentityIds ?? new ChangeTrackingList(), + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + 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(LoadTest)} does not support writing '{options.Format}' format."); + } + } + + LoadTest 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 DeserializeLoadTest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LoadTest)} 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 LoadTest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeLoadTest(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTest.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTest.cs new file mode 100644 index 000000000000..952f3a416ebc --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTest.cs @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Load test model. + public partial class LoadTest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public LoadTest() + { + Secrets = new ChangeTrackingDictionary(); + EnvironmentVariables = new ChangeTrackingDictionary(); + EngineBuiltInIdentityIds = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Pass fail criteria for a test. + /// Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. + /// + /// Secrets can be stored in an Azure Key Vault or any other secret store. If the + /// secret is stored in an Azure Key Vault, the value should be the secret + /// identifier and the type should be AKV_SECRET_URI. If the secret is stored + /// elsewhere, the secret value should be provided directly and the type should be + /// SECRET_VALUE. + /// + /// Certificates metadata. + /// Environment variables which are defined as a set of <name,value> pairs. + /// The load test configuration. + /// Id of the test run to be marked as baseline to view trends of client-side metrics from recent test runs. + /// The input artifacts for the test. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The test description. + /// Display name of a test. + /// Subnet ID on which the load test instances should run. + /// Kind of test. + /// Inject load test engines without deploying public IP for outbound access. + /// Type of the managed identity referencing the Key vault. + /// Resource Id of the managed identity referencing the Key vault. + /// Type of the managed identity referencing the metrics. + /// Resource Id of the managed identity referencing the metrics. + /// Type of the managed identity built in load test engines. + /// Resource Ids of the managed identity built in to load test engines. Required if engineBuiltInIdentityType is UserAssigned. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal LoadTest(PassFailCriteria passFailCriteria, AutoStopCriteria autoStopCriteria, IDictionary secrets, TestCertificate certificate, IDictionary environmentVariables, LoadTestConfiguration loadTestConfiguration, string baselineTestRunId, TestInputArtifacts inputArtifacts, string testId, string description, string displayName, string subnetId, LoadTestKind? kind, bool? publicIpDisabled, string keyvaultReferenceIdentityType, string keyvaultReferenceIdentityId, LoadTestingManagedIdentityType? metricsReferenceIdentityType, string metricsReferenceIdentityId, LoadTestingManagedIdentityType? engineBuiltInIdentityType, IList engineBuiltInIdentityIds, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + { + PassFailCriteria = passFailCriteria; + AutoStopCriteria = autoStopCriteria; + Secrets = secrets; + Certificate = certificate; + EnvironmentVariables = environmentVariables; + LoadTestConfiguration = loadTestConfiguration; + BaselineTestRunId = baselineTestRunId; + InputArtifacts = inputArtifacts; + TestId = testId; + Description = description; + DisplayName = displayName; + SubnetId = subnetId; + Kind = kind; + PublicIpDisabled = publicIpDisabled; + KeyvaultReferenceIdentityType = keyvaultReferenceIdentityType; + KeyvaultReferenceIdentityId = keyvaultReferenceIdentityId; + MetricsReferenceIdentityType = metricsReferenceIdentityType; + MetricsReferenceIdentityId = metricsReferenceIdentityId; + EngineBuiltInIdentityType = engineBuiltInIdentityType; + EngineBuiltInIdentityIds = engineBuiltInIdentityIds; + CreatedDateTime = createdDateTime; + CreatedBy = createdBy; + LastModifiedDateTime = lastModifiedDateTime; + LastModifiedBy = lastModifiedBy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Pass fail criteria for a test. + public PassFailCriteria PassFailCriteria { get; set; } + /// Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. + public AutoStopCriteria AutoStopCriteria { get; set; } + /// + /// Secrets can be stored in an Azure Key Vault or any other secret store. If the + /// secret is stored in an Azure Key Vault, the value should be the secret + /// identifier and the type should be AKV_SECRET_URI. If the secret is stored + /// elsewhere, the secret value should be provided directly and the type should be + /// SECRET_VALUE. + /// + public IDictionary Secrets { get; } + /// Certificates metadata. + public TestCertificate Certificate { get; set; } + /// Environment variables which are defined as a set of <name,value> pairs. + public IDictionary EnvironmentVariables { get; } + /// The load test configuration. + public LoadTestConfiguration LoadTestConfiguration { get; set; } + /// Id of the test run to be marked as baseline to view trends of client-side metrics from recent test runs. + public string BaselineTestRunId { get; set; } + /// The input artifacts for the test. + public TestInputArtifacts InputArtifacts { get; } + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + public string TestId { get; } + /// The test description. + public string Description { get; set; } + /// Display name of a test. + public string DisplayName { get; set; } + /// Subnet ID on which the load test instances should run. + public string SubnetId { get; set; } + /// Kind of test. + public LoadTestKind? Kind { get; set; } + /// Inject load test engines without deploying public IP for outbound access. + public bool? PublicIpDisabled { get; set; } + /// Type of the managed identity referencing the Key vault. + public string KeyvaultReferenceIdentityType { get; set; } + /// Resource Id of the managed identity referencing the Key vault. + public string KeyvaultReferenceIdentityId { get; set; } + /// Type of the managed identity referencing the metrics. + public LoadTestingManagedIdentityType? MetricsReferenceIdentityType { get; set; } + /// Resource Id of the managed identity referencing the metrics. + public string MetricsReferenceIdentityId { get; set; } + /// Type of the managed identity built in load test engines. + public LoadTestingManagedIdentityType? EngineBuiltInIdentityType { get; set; } + /// Resource Ids of the managed identity built in to load test engines. Required if engineBuiltInIdentityType is UserAssigned. + public IList EngineBuiltInIdentityIds { get; } + /// The creation datetime(RFC 3339 literal format). + public DateTimeOffset? CreatedDateTime { get; } + /// The user that created. + public string CreatedBy { get; } + /// The last Modified datetime(RFC 3339 literal format). + public DateTimeOffset? LastModifiedDateTime { get; } + /// The user that last modified. + public string LastModifiedBy { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestAdministrationClient.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestAdministrationClient.cs new file mode 100644 index 000000000000..e27c94d52d61 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestAdministrationClient.cs @@ -0,0 +1,3127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + // Data plane generated client. + /// The LoadTestAdministration service client. + public partial class LoadTestAdministrationClient + { + private static readonly string[] AuthorizationScopes = new string[] { "https://cnt-prod.loadtesting.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of LoadTestAdministrationClient for mocking. + protected LoadTestAdministrationClient() + { + } + + /// Initializes a new instance of LoadTestAdministrationClient. + /// The to use. + /// A credential used to authenticate to an Azure Service. + /// or is null. + public LoadTestAdministrationClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new AzureDeveloperLoadTestingClientOptions()) + { + } + + /// Initializes a new instance of LoadTestAdministrationClient. + /// The to use. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public LoadTestAdministrationClient(Uri endpoint, TokenCredential credential, AzureDeveloperLoadTestingClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new AzureDeveloperLoadTestingClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _tokenCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier()); + _endpoint = endpoint; + _apiVersion = options.Version; + } + + /// + /// [Protocol Method] Create a new test or update an existing test by providing the test Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 CreateOrUpdateTestAsync(string testId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateTest"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTestRequest(testId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create a new test or update an existing test by providing the test Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 CreateOrUpdateTest(string testId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateTest"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTestRequest(testId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Add an app component to a test. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// 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 CreateOrUpdateAppComponentsAsync(string testId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateAppComponents"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateAppComponentsRequest(testId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Add an app component to a test. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// 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 CreateOrUpdateAppComponents(string testId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateAppComponents"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateAppComponentsRequest(testId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Configure server metrics for a test + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// 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 CreateOrUpdateServerMetricsConfigAsync(string testId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateServerMetricsConfig"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateServerMetricsConfigRequest(testId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Configure server metrics for a test + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// 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 CreateOrUpdateServerMetricsConfig(string testId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateServerMetricsConfig"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateServerMetricsConfigRequest(testId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get associated app component (collection of azure resources) for the given test. + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAppComponentsAsync(string testId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAppComponentsAsync(testId, context).ConfigureAwait(false); + return Response.FromValue(TestAppComponents.FromResponse(response), response); + } + + /// Get associated app component (collection of azure resources) for the given test. + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetAppComponents(string testId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAppComponents(testId, context); + return Response.FromValue(TestAppComponents.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get associated app component (collection of azure resources) for the given test. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// 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 GetAppComponentsAsync(string testId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetAppComponents"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAppComponentsRequest(testId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get associated app component (collection of azure resources) for the given test. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// 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 GetAppComponents(string testId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetAppComponents"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAppComponentsRequest(testId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List server metrics configuration for the given test. + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetServerMetricsConfigAsync(string testId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetServerMetricsConfigAsync(testId, context).ConfigureAwait(false); + return Response.FromValue(TestServerMetricsConfiguration.FromResponse(response), response); + } + + /// List server metrics configuration for the given test. + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetServerMetricsConfig(string testId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetServerMetricsConfig(testId, context); + return Response.FromValue(TestServerMetricsConfiguration.FromResponse(response), response); + } + + /// + /// [Protocol Method] List server metrics configuration for the given test. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// 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 GetServerMetricsConfigAsync(string testId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetServerMetricsConfig"); + scope.Start(); + try + { + using HttpMessage message = CreateGetServerMetricsConfigRequest(testId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] List server metrics configuration for the given test. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// 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 GetServerMetricsConfig(string testId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetServerMetricsConfig"); + scope.Start(); + try + { + using HttpMessage message = CreateGetServerMetricsConfigRequest(testId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get load test details by test Id. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetTestAsync(string testId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetTestAsync(testId, context).ConfigureAwait(false); + return Response.FromValue(LoadTest.FromResponse(response), response); + } + + /// Get load test details by test Id. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetTest(string testId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetTest(testId, context); + return Response.FromValue(LoadTest.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get load test details by test Id + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 GetTestAsync(string testId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTest"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestRequest(testId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get load test details by test Id + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 GetTest(string testId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTest"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestRequest(testId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get all the files that are associated with a test. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> GetTestFileAsync(string testId, string fileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetTestFileAsync(testId, fileName, context).ConfigureAwait(false); + return Response.FromValue(TestFileInfo.FromResponse(response), response); + } + + /// Get all the files that are associated with a test. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response GetTestFile(string testId, string fileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetTestFile(testId, fileName, context); + return Response.FromValue(TestFileInfo.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get all the files that are associated with a test. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetTestFileAsync(string testId, string fileName, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestFile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestFileRequest(testId, fileName, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get all the files that are associated with a test. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual Response GetTestFile(string testId, string fileName, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestFile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestFileRequest(testId, fileName, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Upload input file for a given test Id. File size can't be more than 50 MB. + /// Existing file with same name for the given test will be overwritten. File + /// should be provided in the request body as application/octet-stream. + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Unique name for test file with file extension like : App.jmx. + /// The file content as application/octet-stream. + /// File type. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + internal virtual async Task> UploadTestFileAsync(string testId, string fileName, BinaryData body, LoadTestingFileType? fileType = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body; + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await UploadTestFileAsync(testId, fileName, content, fileType?.ToString(), context).ConfigureAwait(false); + return Response.FromValue(TestFileInfo.FromResponse(response), response); + } + + /// + /// Upload input file for a given test Id. File size can't be more than 50 MB. + /// Existing file with same name for the given test will be overwritten. File + /// should be provided in the request body as application/octet-stream. + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Unique name for test file with file extension like : App.jmx. + /// The file content as application/octet-stream. + /// File type. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + internal virtual Response UploadTestFile(string testId, string fileName, BinaryData body, LoadTestingFileType? fileType = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body; + RequestContext context = FromCancellationToken(cancellationToken); + Response response = UploadTestFile(testId, fileName, content, fileType?.ToString(), context); + return Response.FromValue(TestFileInfo.FromResponse(response), response); + } + + /// + /// [Protocol Method] Upload input file for a given test Id. File size can't be more than 50 MB. + /// Existing file with same name for the given test will be overwritten. File + /// should be provided in the request body as application/octet-stream. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Unique name for test file with file extension like : App.jmx. + /// The content to send as the body of the request. + /// File type. Allowed values: "JMX_FILE" | "USER_PROPERTIES" | "ADDITIONAL_ARTIFACTS" | "ZIPPED_ARTIFACTS" | "URL_TEST_CONFIG" | "TEST_SCRIPT". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual async Task UploadTestFileAsync(string testId, string fileName, RequestContent content, string fileType = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.UploadTestFile"); + scope.Start(); + try + { + using HttpMessage message = CreateUploadTestFileRequest(testId, fileName, content, fileType, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Upload input file for a given test Id. File size can't be more than 50 MB. + /// Existing file with same name for the given test will be overwritten. File + /// should be provided in the request body as application/octet-stream. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Unique name for test file with file extension like : App.jmx. + /// The content to send as the body of the request. + /// File type. Allowed values: "JMX_FILE" | "USER_PROPERTIES" | "ADDITIONAL_ARTIFACTS" | "ZIPPED_ARTIFACTS" | "URL_TEST_CONFIG" | "TEST_SCRIPT". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual Response UploadTestFile(string testId, string fileName, RequestContent content, string fileType = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.UploadTestFile"); + scope.Start(); + try + { + using HttpMessage message = CreateUploadTestFileRequest(testId, fileName, content, fileType, 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 file by the file name for a test + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task DeleteTestFileAsync(string testId, string fileName, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTestFile"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestFileRequest(testId, fileName, 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 file by the file name for a test + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual Response DeleteTestFile(string testId, string fileName, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTestFile"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestFileRequest(testId, fileName, 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 test by its test Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 DeleteTestAsync(string testId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTest"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestRequest(testId, 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 test by its test Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 DeleteTest(string testId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTest"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestRequest(testId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create a new test profile or update an existing test profile. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 CreateOrUpdateTestProfileAsync(string testProfileId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateTestProfile"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTestProfileRequest(testProfileId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create a new test profile or update an existing test profile. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 CreateOrUpdateTestProfile(string testProfileId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateTestProfile"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTestProfileRequest(testProfileId, 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 test profile. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 DeleteTestProfileAsync(string testProfileId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTestProfile"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestProfileRequest(testProfileId, 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 test profile. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 DeleteTestProfile(string testProfileId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTestProfile"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestProfileRequest(testProfileId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get load test profile details. + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Get load test profile details by test profile Id. + public virtual async Task> GetTestProfileAsync(string testProfileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetTestProfileAsync(testProfileId, context).ConfigureAwait(false); + return Response.FromValue(TestProfile.FromResponse(response), response); + } + + /// Get load test profile details. + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Get load test profile details by test profile Id. + public virtual Response GetTestProfile(string testProfileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetTestProfile(testProfileId, context); + return Response.FromValue(TestProfile.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get load test profile details. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 GetTestProfileAsync(string testProfileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestProfile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestProfileRequest(testProfileId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get load test profile details. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 GetTestProfile(string testProfileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestProfile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestProfileRequest(testProfileId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create or update operation template. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The unique identifier of the trigger. + /// 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 CreateOrUpdateTriggerAsync(string triggerId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateTrigger"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTriggerRequest(triggerId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create or update operation template. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The unique identifier of the trigger. + /// 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 CreateOrUpdateTrigger(string triggerId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateTrigger"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTriggerRequest(triggerId, 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] Resource delete operation template. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The unique identifier of the trigger. + /// 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 DeleteTriggerAsync(string triggerId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTrigger"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTriggerRequest(triggerId, 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] Resource delete operation template. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The unique identifier of the trigger. + /// 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 DeleteTrigger(string triggerId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTrigger"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTriggerRequest(triggerId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Resource read operation template. + /// The unique identifier of the trigger. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetTriggerAsync(string triggerId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetTriggerAsync(triggerId, context).ConfigureAwait(false); + return Response.FromValue(Trigger.FromResponse(response), response); + } + + /// Resource read operation template. + /// The unique identifier of the trigger. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetTrigger(string triggerId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetTrigger(triggerId, context); + return Response.FromValue(Trigger.FromResponse(response), response); + } + + /// + /// [Protocol Method] Resource read operation template. + /// + /// + /// + /// 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 unique identifier of the trigger. + /// 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 GetTriggerAsync(string triggerId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTrigger"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTriggerRequest(triggerId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Resource read operation template. + /// + /// + /// + /// 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 unique identifier of the trigger. + /// 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 GetTrigger(string triggerId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTrigger"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTriggerRequest(triggerId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create or update operation template. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The unique identifier of the notification rule. + /// 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 CreateOrUpdateNotificationRuleAsync(string notificationRuleId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateNotificationRule"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateNotificationRuleRequest(notificationRuleId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create or update operation template. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The unique identifier of the notification rule. + /// 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 CreateOrUpdateNotificationRule(string notificationRuleId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateNotificationRule"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateNotificationRuleRequest(notificationRuleId, 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] Resource delete operation template. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The unique identifier of the notification rule. + /// 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 DeleteNotificationRuleAsync(string notificationRuleId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteNotificationRule"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteNotificationRuleRequest(notificationRuleId, 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] Resource delete operation template. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The unique identifier of the notification rule. + /// 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 DeleteNotificationRule(string notificationRuleId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteNotificationRule"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteNotificationRuleRequest(notificationRuleId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Resource read operation template. + /// The unique identifier of the notification rule. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetNotificationRuleAsync(string notificationRuleId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetNotificationRuleAsync(notificationRuleId, context).ConfigureAwait(false); + return Response.FromValue(NotificationRule.FromResponse(response), response); + } + + /// Resource read operation template. + /// The unique identifier of the notification rule. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetNotificationRule(string notificationRuleId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetNotificationRule(notificationRuleId, context); + return Response.FromValue(NotificationRule.FromResponse(response), response); + } + + /// + /// [Protocol Method] Resource read operation template. + /// + /// + /// + /// 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 unique identifier of the notification rule. + /// 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 GetNotificationRuleAsync(string notificationRuleId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetNotificationRule"); + scope.Start(); + try + { + using HttpMessage message = CreateGetNotificationRuleRequest(notificationRuleId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Resource read operation template. + /// + /// + /// + /// 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 unique identifier of the notification rule. + /// 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 GetNotificationRule(string notificationRuleId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetNotificationRule"); + scope.Start(); + try + { + using HttpMessage message = CreateGetNotificationRuleRequest(notificationRuleId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get the status of a long running operation. + /// The unique ID of the operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetOperationStatusAsync(string operationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetOperationStatusAsync(operationId, context).ConfigureAwait(false); + return Response.FromValue(OperationStatus.FromResponse(response), response); + } + + /// Get the status of a long running operation. + /// The unique ID of the operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetOperationStatus(string operationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetOperationStatus(operationId, context); + return Response.FromValue(OperationStatus.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get the status of a long running operation. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The unique ID of the operation. + /// 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 GetOperationStatusAsync(string operationId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetOperationStatus"); + scope.Start(); + try + { + using HttpMessage message = CreateGetOperationStatusRequest(operationId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get the status of a long running operation. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The unique ID of the operation. + /// 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 GetOperationStatus(string operationId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetOperationStatus"); + scope.Start(); + try + { + using HttpMessage message = CreateGetOperationStatusRequest(operationId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get all test files. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual AsyncPageable GetTestFilesAsync(string testId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestFilesRequest(testId, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestFilesNextPageRequest(nextLink, testId, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => TestFileInfo.DeserializeTestFileInfo(e), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTestFiles", "value", "nextLink", context); + } + + /// Get all test files. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Pageable GetTestFiles(string testId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestFilesRequest(testId, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestFilesNextPageRequest(nextLink, testId, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => TestFileInfo.DeserializeTestFileInfo(e), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTestFiles", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Get all test files. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + public virtual AsyncPageable GetTestFilesAsync(string testId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestFilesRequest(testId, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestFilesNextPageRequest(nextLink, testId, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTestFiles", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Get all test files. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + public virtual Pageable GetTestFiles(string testId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestFilesRequest(testId, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestFilesNextPageRequest(nextLink, testId, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTestFiles", "value", "nextLink", context); + } + + /// + /// Get all load tests by the fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + /// + /// + /// Sort on the supported fields in (field asc/desc) format. eg: + /// lastModifiedDateTime asc. Supported fields - lastModifiedDateTime + /// + /// + /// Prefix based, case sensitive search on searchable fields - displayName, + /// createdBy. For example, to search for a test, with display name is Login Test, + /// the search parameter can be Login. + /// + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter tests. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter tests. + /// Number of results in response. + /// The cancellation token to use. + public virtual AsyncPageable GetTestsAsync(string orderby = null, string search = null, DateTimeOffset? lastModifiedStartTime = null, DateTimeOffset? lastModifiedEndTime = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestsRequest(orderby, search, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestsNextPageRequest(nextLink, orderby, search, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => LoadTest.DeserializeLoadTest(e), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTests", "value", "nextLink", maxpagesize, context); + } + + /// + /// Get all load tests by the fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + /// + /// + /// Sort on the supported fields in (field asc/desc) format. eg: + /// lastModifiedDateTime asc. Supported fields - lastModifiedDateTime + /// + /// + /// Prefix based, case sensitive search on searchable fields - displayName, + /// createdBy. For example, to search for a test, with display name is Login Test, + /// the search parameter can be Login. + /// + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter tests. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter tests. + /// Number of results in response. + /// The cancellation token to use. + public virtual Pageable GetTests(string orderby = null, string search = null, DateTimeOffset? lastModifiedStartTime = null, DateTimeOffset? lastModifiedEndTime = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestsRequest(orderby, search, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestsNextPageRequest(nextLink, orderby, search, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => LoadTest.DeserializeLoadTest(e), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTests", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] Get all load tests by the fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// + /// Sort on the supported fields in (field asc/desc) format. eg: + /// lastModifiedDateTime asc. Supported fields - lastModifiedDateTime + /// + /// + /// Prefix based, case sensitive search on searchable fields - displayName, + /// createdBy. For example, to search for a test, with display name is Login Test, + /// the search parameter can be Login. + /// + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter tests. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter tests. + /// Number of results in response. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + public virtual AsyncPageable GetTestsAsync(string orderby, string search, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestsRequest(orderby, search, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestsNextPageRequest(nextLink, orderby, search, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTests", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] Get all load tests by the fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// + /// Sort on the supported fields in (field asc/desc) format. eg: + /// lastModifiedDateTime asc. Supported fields - lastModifiedDateTime + /// + /// + /// Prefix based, case sensitive search on searchable fields - displayName, + /// createdBy. For example, to search for a test, with display name is Login Test, + /// the search parameter can be Login. + /// + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter tests. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter tests. + /// Number of results in response. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + public virtual Pageable GetTests(string orderby, string search, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestsRequest(orderby, search, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestsNextPageRequest(nextLink, orderby, search, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTests", "value", "nextLink", maxpagesize, context); + } + + /// List test profiles. + /// Maximum number of results to include in a single response. + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter test profiles. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter test profiles. + /// Comma separated list of IDs of the test profiles to filter. + /// Comma separated list IDs of the tests which should be associated with the test profiles to fetch. + /// The cancellation token to use. + /// Get all test profiles for the given filters. + public virtual AsyncPageable GetTestProfilesAsync(int? maxpagesize = null, DateTimeOffset? lastModifiedStartTime = null, DateTimeOffset? lastModifiedEndTime = null, IEnumerable testProfileIds = null, IEnumerable testIds = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestProfilesRequest(pageSizeHint, lastModifiedStartTime, lastModifiedEndTime, testProfileIds, testIds, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestProfilesNextPageRequest(nextLink, pageSizeHint, lastModifiedStartTime, lastModifiedEndTime, testProfileIds, testIds, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => TestProfile.DeserializeTestProfile(e), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTestProfiles", "value", "nextLink", maxpagesize, context); + } + + /// List test profiles. + /// Maximum number of results to include in a single response. + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter test profiles. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter test profiles. + /// Comma separated list of IDs of the test profiles to filter. + /// Comma separated list IDs of the tests which should be associated with the test profiles to fetch. + /// The cancellation token to use. + /// Get all test profiles for the given filters. + public virtual Pageable GetTestProfiles(int? maxpagesize = null, DateTimeOffset? lastModifiedStartTime = null, DateTimeOffset? lastModifiedEndTime = null, IEnumerable testProfileIds = null, IEnumerable testIds = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestProfilesRequest(pageSizeHint, lastModifiedStartTime, lastModifiedEndTime, testProfileIds, testIds, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestProfilesNextPageRequest(nextLink, pageSizeHint, lastModifiedStartTime, lastModifiedEndTime, testProfileIds, testIds, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => TestProfile.DeserializeTestProfile(e), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTestProfiles", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] List test profiles. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Maximum number of results to include in a single response. + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter test profiles. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter test profiles. + /// Comma separated list of IDs of the test profiles to filter. + /// Comma separated list IDs of the tests which should be associated with the test profiles to fetch. + /// 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 GetTestProfilesAsync(int? maxpagesize, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, IEnumerable testProfileIds, IEnumerable testIds, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestProfilesRequest(pageSizeHint, lastModifiedStartTime, lastModifiedEndTime, testProfileIds, testIds, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestProfilesNextPageRequest(nextLink, pageSizeHint, lastModifiedStartTime, lastModifiedEndTime, testProfileIds, testIds, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTestProfiles", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] List test profiles. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Maximum number of results to include in a single response. + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter test profiles. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter test profiles. + /// Comma separated list of IDs of the test profiles to filter. + /// Comma separated list IDs of the tests which should be associated with the test profiles to fetch. + /// 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 GetTestProfiles(int? maxpagesize, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, IEnumerable testProfileIds, IEnumerable testIds, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestProfilesRequest(pageSizeHint, lastModifiedStartTime, lastModifiedEndTime, testProfileIds, testIds, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestProfilesNextPageRequest(nextLink, pageSizeHint, lastModifiedStartTime, lastModifiedEndTime, testProfileIds, testIds, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTestProfiles", "value", "nextLink", maxpagesize, context); + } + + /// Resource list operation template. + /// Search based on triggers associated with the provided test ids. + /// Filter triggers based on a comma separated list of states. + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter triggers. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter triggers. + /// Number of results in response. Default page size is 50. + /// The cancellation token to use. + public virtual AsyncPageable GetTriggersAsync(string testIds = null, TriggerState? states = null, DateTimeOffset? lastModifiedStartTime = null, DateTimeOffset? lastModifiedEndTime = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTriggersRequest(testIds, states?.ToString(), lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTriggersNextPageRequest(nextLink, testIds, states?.ToString(), lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Trigger.DeserializeTrigger(e), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTriggers", "value", "nextLink", maxpagesize, context); + } + + /// Resource list operation template. + /// Search based on triggers associated with the provided test ids. + /// Filter triggers based on a comma separated list of states. + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter triggers. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter triggers. + /// Number of results in response. Default page size is 50. + /// The cancellation token to use. + public virtual Pageable GetTriggers(string testIds = null, TriggerState? states = null, DateTimeOffset? lastModifiedStartTime = null, DateTimeOffset? lastModifiedEndTime = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTriggersRequest(testIds, states?.ToString(), lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTriggersNextPageRequest(nextLink, testIds, states?.ToString(), lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Trigger.DeserializeTrigger(e), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTriggers", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] Resource list operation template. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Search based on triggers associated with the provided test ids. + /// Filter triggers based on a comma separated list of states. Allowed values: "Active" | "Paused" | "Completed" | "Disabled". + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter triggers. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter triggers. + /// Number of results in response. Default page size is 50. + /// 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 GetTriggersAsync(string testIds, string states, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTriggersRequest(testIds, states, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTriggersNextPageRequest(nextLink, testIds, states, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTriggers", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] Resource list operation template. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Search based on triggers associated with the provided test ids. + /// Filter triggers based on a comma separated list of states. Allowed values: "Active" | "Paused" | "Completed" | "Disabled". + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter triggers. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter triggers. + /// Number of results in response. Default page size is 50. + /// 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 GetTriggers(string testIds, string states, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTriggersRequest(testIds, states, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTriggersNextPageRequest(nextLink, testIds, states, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTriggers", "value", "nextLink", maxpagesize, context); + } + + /// Resource list operation template. + /// Search based on notification rules associated with the provided test ids. + /// Search based on notification rules for the provided scopes. + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter notification rules. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter notification rules. + /// Number of results in response. Default page size is 50. + /// The cancellation token to use. + public virtual AsyncPageable GetNotificationRulesAsync(string testIds = null, string scopes = null, DateTimeOffset? lastModifiedStartTime = null, DateTimeOffset? lastModifiedEndTime = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetNotificationRulesRequest(testIds, scopes, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetNotificationRulesNextPageRequest(nextLink, testIds, scopes, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => NotificationRule.DeserializeNotificationRule(e), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetNotificationRules", "value", "nextLink", maxpagesize, context); + } + + /// Resource list operation template. + /// Search based on notification rules associated with the provided test ids. + /// Search based on notification rules for the provided scopes. + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter notification rules. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter notification rules. + /// Number of results in response. Default page size is 50. + /// The cancellation token to use. + public virtual Pageable GetNotificationRules(string testIds = null, string scopes = null, DateTimeOffset? lastModifiedStartTime = null, DateTimeOffset? lastModifiedEndTime = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetNotificationRulesRequest(testIds, scopes, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetNotificationRulesNextPageRequest(nextLink, testIds, scopes, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => NotificationRule.DeserializeNotificationRule(e), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetNotificationRules", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] Resource list operation template. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Search based on notification rules associated with the provided test ids. + /// Search based on notification rules for the provided scopes. + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter notification rules. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter notification rules. + /// Number of results in response. Default page size is 50. + /// 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 GetNotificationRulesAsync(string testIds, string scopes, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetNotificationRulesRequest(testIds, scopes, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetNotificationRulesNextPageRequest(nextLink, testIds, scopes, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetNotificationRules", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] Resource list operation template. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Search based on notification rules associated with the provided test ids. + /// Search based on notification rules for the provided scopes. + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter notification rules. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter notification rules. + /// Number of results in response. Default page size is 50. + /// 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 GetNotificationRules(string testIds, string scopes, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetNotificationRulesRequest(testIds, scopes, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetNotificationRulesNextPageRequest(nextLink, testIds, scopes, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetNotificationRules", "value", "nextLink", maxpagesize, context); + } + + /// Clone a load test. + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Unique identifier for the new test that will be created. + /// Display Name override for the newly created test. + /// Description override for the newly created test. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Clone the given test with optional overrides applied to the clone test. + public virtual async Task> CloneTestAsync(WaitUntil waitUntil, string testId, string newTestId, string displayName = null, string description = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(newTestId, nameof(newTestId)); + + CloneTestRequest1 cloneTestRequest1 = new CloneTestRequest1(newTestId, displayName, description, null); + RequestContext context = FromCancellationToken(cancellationToken); + Operation response = await CloneTestAsync(waitUntil, testId, cloneTestRequest1.ToRequestContent(), context).ConfigureAwait(false); + return ProtocolOperationHelpers.Convert(response, LoadTest.FromResponse, ClientDiagnostics, "LoadTestAdministrationClient.CloneTest"); + } + + /// Clone a load test. + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Unique identifier for the new test that will be created. + /// Display Name override for the newly created test. + /// Description override for the newly created test. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Clone the given test with optional overrides applied to the clone test. + public virtual Operation CloneTest(WaitUntil waitUntil, string testId, string newTestId, string displayName = null, string description = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(newTestId, nameof(newTestId)); + + CloneTestRequest1 cloneTestRequest1 = new CloneTestRequest1(newTestId, displayName, description, null); + RequestContext context = FromCancellationToken(cancellationToken); + Operation response = CloneTest(waitUntil, testId, cloneTestRequest1.ToRequestContent(), context); + return ProtocolOperationHelpers.Convert(response, LoadTest.FromResponse, ClientDiagnostics, "LoadTestAdministrationClient.CloneTest"); + } + + /// + /// [Protocol Method] Clone a load test. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 representing an asynchronous operation on the service. + public virtual async Task> CloneTestAsync(WaitUntil waitUntil, string testId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CloneTest"); + scope.Start(); + try + { + using HttpMessage message = CreateCloneTestRequest(testId, content, context); + return await ProtocolOperationHelpers.ProcessMessageAsync(_pipeline, message, ClientDiagnostics, "LoadTestAdministrationClient.CloneTest", OperationFinalStateVia.OperationLocation, context, waitUntil).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Clone a load test. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 representing an asynchronous operation on the service. + public virtual Operation CloneTest(WaitUntil waitUntil, string testId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CloneTest"); + scope.Start(); + try + { + using HttpMessage message = CreateCloneTestRequest(testId, content, context); + return ProtocolOperationHelpers.ProcessMessage(_pipeline, message, ClientDiagnostics, "LoadTestAdministrationClient.CloneTest", OperationFinalStateVia.OperationLocation, context, waitUntil); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateCreateOrUpdateTestRequest(string testId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateCreateOrUpdateAppComponentsRequest(string testId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/app-components", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateCreateOrUpdateServerMetricsConfigRequest(string testId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/server-metrics-config", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetAppComponentsRequest(string testId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/app-components", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetServerMetricsConfigRequest(string testId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/server-metrics-config", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestRequest(string testId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestFileRequest(string testId, string fileName, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/files/", false); + uri.AppendPath(fileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestFilesRequest(string testId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/files", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestsRequest(string orderby, string search, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (orderby != null) + { + uri.AppendQuery("orderby", orderby, true); + } + if (search != null) + { + uri.AppendQuery("search", search, true); + } + if (lastModifiedStartTime != null) + { + uri.AppendQuery("lastModifiedStartTime", lastModifiedStartTime.Value, "O", true); + } + if (lastModifiedEndTime != null) + { + uri.AppendQuery("lastModifiedEndTime", lastModifiedEndTime.Value, "O", true); + } + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateUploadTestFileRequest(string testId, string fileName, RequestContent content, string fileType, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier201); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/files/", false); + uri.AppendPath(fileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + if (fileType != null) + { + uri.AppendQuery("fileType", fileType, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/octet-stream"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteTestFileRequest(string testId, string fileName, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/files/", false); + uri.AppendPath(fileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateDeleteTestRequest(string testId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateTestProfileRequest(string testProfileId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-profiles/", false); + uri.AppendPath(testProfileId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteTestProfileRequest(string testProfileId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-profiles/", false); + uri.AppendPath(testProfileId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestProfileRequest(string testProfileId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-profiles/", false); + uri.AppendPath(testProfileId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestProfilesRequest(int? maxpagesize, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, IEnumerable testProfileIds, IEnumerable testIds, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-profiles", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } + if (lastModifiedStartTime != null) + { + uri.AppendQuery("lastModifiedStartTime", lastModifiedStartTime.Value, "O", true); + } + if (lastModifiedEndTime != null) + { + uri.AppendQuery("lastModifiedEndTime", lastModifiedEndTime.Value, "O", true); + } + if (testProfileIds != null && !(testProfileIds is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) + { + uri.AppendQueryDelimited("testProfileIds", testProfileIds, ",", true); + } + if (testIds != null && !(testIds is ChangeTrackingList changeTrackingList0 && changeTrackingList0.IsUndefined)) + { + uri.AppendQueryDelimited("testIds", testIds, ",", true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateTriggerRequest(string triggerId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/triggers/", false); + uri.AppendPath(triggerId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteTriggerRequest(string triggerId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/triggers/", false); + uri.AppendPath(triggerId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTriggerRequest(string triggerId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/triggers/", false); + uri.AppendPath(triggerId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTriggersRequest(string testIds, string states, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/triggers", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (testIds != null) + { + uri.AppendQuery("testIds", testIds, true); + } + if (states != null) + { + uri.AppendQuery("states", states, true); + } + if (lastModifiedStartTime != null) + { + uri.AppendQuery("lastModifiedStartTime", lastModifiedStartTime.Value, "O", true); + } + if (lastModifiedEndTime != null) + { + uri.AppendQuery("lastModifiedEndTime", lastModifiedEndTime.Value, "O", true); + } + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateNotificationRuleRequest(string notificationRuleId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/notification-rules/", false); + uri.AppendPath(notificationRuleId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteNotificationRuleRequest(string notificationRuleId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/notification-rules/", false); + uri.AppendPath(notificationRuleId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetNotificationRuleRequest(string notificationRuleId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/notification-rules/", false); + uri.AppendPath(notificationRuleId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetNotificationRulesRequest(string testIds, string scopes, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/notification-rules", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (testIds != null) + { + uri.AppendQuery("testIds", testIds, true); + } + if (scopes != null) + { + uri.AppendQuery("scopes", scopes, true); + } + if (lastModifiedStartTime != null) + { + uri.AppendQuery("lastModifiedStartTime", lastModifiedStartTime.Value, "O", true); + } + if (lastModifiedEndTime != null) + { + uri.AppendQuery("lastModifiedEndTime", lastModifiedEndTime.Value, "O", true); + } + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCloneTestRequest(string testId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier202); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath(":clone", 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 CreateGetOperationStatusRequest(string operationId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/operations/", false); + uri.AppendPath(operationId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestFilesNextPageRequest(string nextLink, string testId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestsNextPageRequest(string nextLink, string orderby, string search, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestProfilesNextPageRequest(string nextLink, int? maxpagesize, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, IEnumerable testProfileIds, IEnumerable testIds, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTriggersNextPageRequest(string nextLink, string testIds, string states, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetNotificationRulesNextPageRequest(string nextLink, string testIds, string scopes, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + 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 _responseClassifier200201; + private static ResponseClassifier ResponseClassifier200201 => _responseClassifier200201 ??= new StatusCodeClassifier(stackalloc ushort[] { 200, 201 }); + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + private static ResponseClassifier _responseClassifier201; + private static ResponseClassifier ResponseClassifier201 => _responseClassifier201 ??= new StatusCodeClassifier(stackalloc ushort[] { 201 }); + private static ResponseClassifier _responseClassifier204; + private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); + private static ResponseClassifier _responseClassifier202; + private static ResponseClassifier ResponseClassifier202 => _responseClassifier202 ??= new StatusCodeClassifier(stackalloc ushort[] { 202 }); + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestConfiguration.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestConfiguration.Serialization.cs new file mode 100644 index 000000000000..b4a9f6ddead2 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestConfiguration.Serialization.cs @@ -0,0 +1,225 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class LoadTestConfiguration : 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(LoadTestConfiguration)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(EngineInstances)) + { + writer.WritePropertyName("engineInstances"u8); + writer.WriteNumberValue(EngineInstances.Value); + } + if (Optional.IsDefined(SplitAllCsvs)) + { + writer.WritePropertyName("splitAllCSVs"u8); + writer.WriteBooleanValue(SplitAllCsvs.Value); + } + if (Optional.IsDefined(QuickStartTest)) + { + writer.WritePropertyName("quickStartTest"u8); + writer.WriteBooleanValue(QuickStartTest.Value); + } + if (Optional.IsDefined(OptionalLoadTestConfiguration)) + { + writer.WritePropertyName("optionalLoadTestConfig"u8); + writer.WriteObjectValue(OptionalLoadTestConfiguration, options); + } + if (Optional.IsCollectionDefined(RegionalLoadTestConfiguration)) + { + writer.WritePropertyName("regionalLoadTestConfig"u8); + writer.WriteStartArray(); + foreach (var item in RegionalLoadTestConfiguration) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + LoadTestConfiguration 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(LoadTestConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLoadTestConfiguration(document.RootElement, options); + } + + internal static LoadTestConfiguration DeserializeLoadTestConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? engineInstances = default; + bool? splitAllCSVs = default; + bool? quickStartTest = default; + OptionalLoadTestConfiguration optionalLoadTestConfig = default; + IList regionalLoadTestConfig = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("engineInstances"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + engineInstances = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("splitAllCSVs"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + splitAllCSVs = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("quickStartTest"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + quickStartTest = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("optionalLoadTestConfig"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + optionalLoadTestConfig = OptionalLoadTestConfiguration.DeserializeOptionalLoadTestConfiguration(property.Value, options); + continue; + } + if (property.NameEquals("regionalLoadTestConfig"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RegionalConfiguration.DeserializeRegionalConfiguration(item, options)); + } + regionalLoadTestConfig = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new LoadTestConfiguration( + engineInstances, + splitAllCSVs, + quickStartTest, + optionalLoadTestConfig, + regionalLoadTestConfig ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(LoadTestConfiguration)} does not support writing '{options.Format}' format."); + } + } + + LoadTestConfiguration 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 DeserializeLoadTestConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LoadTestConfiguration)} 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 LoadTestConfiguration FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeLoadTestConfiguration(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestConfiguration.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestConfiguration.cs new file mode 100644 index 000000000000..028e919c5597 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestConfiguration.cs @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Configurations for the load test. + public partial class LoadTestConfiguration + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public LoadTestConfiguration() + { + RegionalLoadTestConfiguration = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The number of engine instances to execute load test. Supported values are in range of 1-400. Required for creating a new test. + /// + /// If false, Azure Load Testing copies and processes your input files unmodified + /// across all test engine instances. If true, Azure Load Testing splits the CSV + /// input data evenly across all engine instances. If you provide multiple CSV + /// files, each file will be split evenly. + /// + /// + /// If true, optionalLoadTestConfig is required and JMX script for the load test is + /// not required to upload. + /// + /// Configuration for quick load test. + /// Region distribution configuration for the load test. + /// Keeps track of any properties unknown to the library. + internal LoadTestConfiguration(int? engineInstances, bool? splitAllCsvs, bool? quickStartTest, OptionalLoadTestConfiguration optionalLoadTestConfiguration, IList regionalLoadTestConfiguration, IDictionary serializedAdditionalRawData) + { + EngineInstances = engineInstances; + SplitAllCsvs = splitAllCsvs; + QuickStartTest = quickStartTest; + OptionalLoadTestConfiguration = optionalLoadTestConfiguration; + RegionalLoadTestConfiguration = regionalLoadTestConfiguration; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The number of engine instances to execute load test. Supported values are in range of 1-400. Required for creating a new test. + public int? EngineInstances { get; set; } + /// + /// If false, Azure Load Testing copies and processes your input files unmodified + /// across all test engine instances. If true, Azure Load Testing splits the CSV + /// input data evenly across all engine instances. If you provide multiple CSV + /// files, each file will be split evenly. + /// + public bool? SplitAllCsvs { get; set; } + /// + /// If true, optionalLoadTestConfig is required and JMX script for the load test is + /// not required to upload. + /// + public bool? QuickStartTest { get; set; } + /// Configuration for quick load test. + public OptionalLoadTestConfiguration OptionalLoadTestConfiguration { get; set; } + /// Region distribution configuration for the load test. + public IList RegionalLoadTestConfiguration { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestKind.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestKind.cs new file mode 100644 index 000000000000..4d7a928d4692 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestKind.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.Developer.LoadTesting +{ + /// Test kind. + public readonly partial struct LoadTestKind : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public LoadTestKind(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UrlValue = "URL"; + private const string JmxValue = "JMX"; + private const string LocustValue = "Locust"; + + /// URL Test. + public static LoadTestKind Url { get; } = new LoadTestKind(UrlValue); + /// JMX Test. + public static LoadTestKind Jmx { get; } = new LoadTestKind(JmxValue); + /// Locust Test. + public static LoadTestKind Locust { get; } = new LoadTestKind(LocustValue); + /// Determines if two values are the same. + public static bool operator ==(LoadTestKind left, LoadTestKind right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(LoadTestKind left, LoadTestKind right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator LoadTestKind(string value) => new LoadTestKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is LoadTestKind other && Equals(other); + /// + public bool Equals(LoadTestKind 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestRun.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestRun.Serialization.cs new file mode 100644 index 000000000000..0a5f5d8ed077 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestRun.Serialization.cs @@ -0,0 +1,705 @@ +// 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.Developer.LoadTesting +{ + public partial class LoadTestRun : 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(LoadTestRun)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("testRunId"u8); + writer.WriteStringValue(TestRunId); + } + if (Optional.IsDefined(PassFailCriteria)) + { + writer.WritePropertyName("passFailCriteria"u8); + writer.WriteObjectValue(PassFailCriteria, options); + } + if (Optional.IsDefined(AutoStopCriteria)) + { + writer.WritePropertyName("autoStopCriteria"u8); + writer.WriteObjectValue(AutoStopCriteria, options); + } + if (Optional.IsCollectionDefined(Secrets)) + { + writer.WritePropertyName("secrets"u8); + writer.WriteStartObject(); + foreach (var item in Secrets) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Certificate)) + { + writer.WritePropertyName("certificate"u8); + writer.WriteObjectValue(Certificate, options); + } + if (Optional.IsCollectionDefined(EnvironmentVariables)) + { + writer.WritePropertyName("environmentVariables"u8); + writer.WriteStartObject(); + foreach (var item in EnvironmentVariables) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(ErrorDetails)) + { + writer.WritePropertyName("errorDetails"u8); + writer.WriteStartArray(); + foreach (var item in ErrorDetails) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(TestRunStatistics)) + { + writer.WritePropertyName("testRunStatistics"u8); + writer.WriteStartObject(); + foreach (var item in TestRunStatistics) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(RegionalStatistics)) + { + writer.WritePropertyName("regionalStatistics"u8); + writer.WriteStartObject(); + foreach (var item in RegionalStatistics) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && Optional.IsDefined(LoadTestConfiguration)) + { + writer.WritePropertyName("loadTestConfiguration"u8); + writer.WriteObjectValue(LoadTestConfiguration, options); + } + if (options.Format != "W" && Optional.IsDefined(TestArtifacts)) + { + writer.WritePropertyName("testArtifacts"u8); + writer.WriteObjectValue(TestArtifacts, options); + } + if (options.Format != "W" && Optional.IsDefined(TestResult)) + { + writer.WritePropertyName("testResult"u8); + writer.WriteStringValue(TestResult.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(VirtualUsers)) + { + writer.WritePropertyName("virtualUsers"u8); + writer.WriteNumberValue(VirtualUsers.Value); + } + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsDefined(TestId)) + { + writer.WritePropertyName("testId"u8); + writer.WriteStringValue(TestId); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(StartDateTime)) + { + writer.WritePropertyName("startDateTime"u8); + writer.WriteStringValue(StartDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(EndDateTime)) + { + writer.WritePropertyName("endDateTime"u8); + writer.WriteStringValue(EndDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ExecutedDateTime)) + { + writer.WritePropertyName("executedDateTime"u8); + writer.WriteStringValue(ExecutedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(PortalUri)) + { + writer.WritePropertyName("portalUrl"u8); + writer.WriteStringValue(PortalUri.AbsoluteUri); + } + if (options.Format != "W" && Optional.IsDefined(Duration)) + { + writer.WritePropertyName("duration"u8); + writer.WriteNumberValue(Duration.Value); + } + if (options.Format != "W" && Optional.IsDefined(VirtualUserHours)) + { + writer.WritePropertyName("virtualUserHours"u8); + writer.WriteNumberValue(VirtualUserHours.Value); + } + if (options.Format != "W" && Optional.IsDefined(SubnetId)) + { + writer.WritePropertyName("subnetId"u8); + writer.WriteStringValue(SubnetId); + } + if (options.Format != "W" && Optional.IsDefined(Kind)) + { + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.Value.ToString()); + } + if (Optional.IsDefined(RequestDataLevel)) + { + writer.WritePropertyName("requestDataLevel"u8); + writer.WriteStringValue(RequestDataLevel.Value.ToString()); + } + if (Optional.IsDefined(DebugLogsEnabled)) + { + writer.WritePropertyName("debugLogsEnabled"u8); + writer.WriteBooleanValue(DebugLogsEnabled.Value); + } + if (options.Format != "W" && Optional.IsDefined(PublicIpDisabled)) + { + writer.WritePropertyName("publicIPDisabled"u8); + writer.WriteBooleanValue(PublicIpDisabled.Value); + } + if (Optional.IsDefined(CreatedByType)) + { + writer.WritePropertyName("createdByType"u8); + writer.WriteStringValue(CreatedByType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(CreatedByUri)) + { + writer.WritePropertyName("createdByUri"u8); + writer.WriteStringValue(CreatedByUri.AbsoluteUri); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedDateTime)) + { + writer.WritePropertyName("lastModifiedDateTime"u8); + writer.WriteStringValue(LastModifiedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedBy)) + { + writer.WritePropertyName("lastModifiedBy"u8); + writer.WriteStringValue(LastModifiedBy); + } + 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 + } + } + } + + LoadTestRun 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(LoadTestRun)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLoadTestRun(document.RootElement, options); + } + + internal static LoadTestRun DeserializeLoadTestRun(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string testRunId = default; + PassFailCriteria passFailCriteria = default; + AutoStopCriteria autoStopCriteria = default; + IDictionary secrets = default; + TestCertificate certificate = default; + IDictionary environmentVariables = default; + IReadOnlyList errorDetails = default; + IReadOnlyDictionary testRunStatistics = default; + IReadOnlyDictionary regionalStatistics = default; + LoadTestConfiguration loadTestConfiguration = default; + TestRunArtifacts testArtifacts = default; + PassFailTestResult? testResult = default; + int? virtualUsers = default; + string displayName = default; + string testId = default; + string description = default; + TestRunStatus? status = default; + DateTimeOffset? startDateTime = default; + DateTimeOffset? endDateTime = default; + DateTimeOffset? executedDateTime = default; + Uri portalUrl = default; + long? duration = default; + double? virtualUserHours = default; + string subnetId = default; + LoadTestKind? kind = default; + RequestDataLevel? requestDataLevel = default; + bool? debugLogsEnabled = default; + bool? publicIPDisabled = default; + CreatedByType? createdByType = default; + Uri createdByUri = default; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("testRunId"u8)) + { + testRunId = property.Value.GetString(); + continue; + } + if (property.NameEquals("passFailCriteria"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + passFailCriteria = PassFailCriteria.DeserializePassFailCriteria(property.Value, options); + continue; + } + if (property.NameEquals("autoStopCriteria"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + autoStopCriteria = AutoStopCriteria.DeserializeAutoStopCriteria(property.Value, options); + continue; + } + if (property.NameEquals("secrets"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, TestSecret.DeserializeTestSecret(property0.Value, options)); + } + secrets = dictionary; + continue; + } + if (property.NameEquals("certificate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + certificate = TestCertificate.DeserializeTestCertificate(property.Value, options); + continue; + } + if (property.NameEquals("environmentVariables"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + environmentVariables = dictionary; + continue; + } + if (property.NameEquals("errorDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(LoadTesting.ErrorDetails.DeserializeErrorDetails(item, options)); + } + errorDetails = array; + continue; + } + if (property.NameEquals("testRunStatistics"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, LoadTesting.TestRunStatistics.DeserializeTestRunStatistics(property0.Value, options)); + } + testRunStatistics = dictionary; + continue; + } + if (property.NameEquals("regionalStatistics"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, LoadTesting.TestRunStatistics.DeserializeTestRunStatistics(property0.Value, options)); + } + regionalStatistics = dictionary; + continue; + } + if (property.NameEquals("loadTestConfiguration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + loadTestConfiguration = LoadTestConfiguration.DeserializeLoadTestConfiguration(property.Value, options); + continue; + } + if (property.NameEquals("testArtifacts"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + testArtifacts = TestRunArtifacts.DeserializeTestRunArtifacts(property.Value, options); + continue; + } + if (property.NameEquals("testResult"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + testResult = new PassFailTestResult(property.Value.GetString()); + continue; + } + if (property.NameEquals("virtualUsers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + virtualUsers = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("testId"u8)) + { + testId = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new TestRunStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("startDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("endDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("executedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + executedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("portalUrl"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + portalUrl = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("duration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + duration = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("virtualUserHours"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + virtualUserHours = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("subnetId"u8)) + { + subnetId = property.Value.GetString(); + continue; + } + if (property.NameEquals("kind"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + kind = new LoadTestKind(property.Value.GetString()); + continue; + } + if (property.NameEquals("requestDataLevel"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + requestDataLevel = new RequestDataLevel(property.Value.GetString()); + continue; + } + if (property.NameEquals("debugLogsEnabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + debugLogsEnabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("publicIPDisabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + publicIPDisabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("createdByType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdByType = new CreatedByType(property.Value.GetString()); + continue; + } + if (property.NameEquals("createdByUri"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdByUri = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new LoadTestRun( + testRunId, + passFailCriteria, + autoStopCriteria, + secrets ?? new ChangeTrackingDictionary(), + certificate, + environmentVariables ?? new ChangeTrackingDictionary(), + errorDetails ?? new ChangeTrackingList(), + testRunStatistics ?? new ChangeTrackingDictionary(), + regionalStatistics ?? new ChangeTrackingDictionary(), + loadTestConfiguration, + testArtifacts, + testResult, + virtualUsers, + displayName, + testId, + description, + status, + startDateTime, + endDateTime, + executedDateTime, + portalUrl, + duration, + virtualUserHours, + subnetId, + kind, + requestDataLevel, + debugLogsEnabled, + publicIPDisabled, + createdByType, + createdByUri, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + 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(LoadTestRun)} does not support writing '{options.Format}' format."); + } + } + + LoadTestRun 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 DeserializeLoadTestRun(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LoadTestRun)} 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 LoadTestRun FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeLoadTestRun(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestRun.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestRun.cs new file mode 100644 index 000000000000..d1e763f62ec8 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestRun.cs @@ -0,0 +1,230 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Load test run model. + public partial class LoadTestRun + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public LoadTestRun() + { + Secrets = new ChangeTrackingDictionary(); + EnvironmentVariables = new ChangeTrackingDictionary(); + ErrorDetails = new ChangeTrackingList(); + TestRunStatistics = new ChangeTrackingDictionary(); + RegionalStatistics = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Pass fail criteria for a test. + /// Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. + /// + /// Secrets can be stored in an Azure Key Vault or any other secret store. If the + /// secret is stored in an Azure Key Vault, the value should be the secret + /// identifier and the type should be AKV_SECRET_URI. If the secret is stored + /// elsewhere, the secret value should be provided directly and the type should be + /// SECRET_VALUE. + /// + /// Certificates metadata. + /// Environment variables which are defined as a set of <name,value> pairs. + /// Error details if there is any failure in load test run. + /// + /// Test run statistics. Key is the sampler name and value is the set of statistics for performance metrics like response time, throughput, etc. from the load test run. + /// The sampler name is the same as the name mentioned in the test script. + /// Sampler name "Total" represents the aggregated statistics of all the samplers. + /// + /// + /// Regional statistics. Key is the Azure region name and value is the test run statistics. + /// The region name should of format accepted by ARM, and should be a region supported by Azure Load Testing. For example, East US should be passed as "eastus". + /// The region name must match one of the strings in the "Name" column returned from running the "az account list-locations -o table" Azure CLI command. + /// + /// The load test configuration. + /// Collection of test run artifacts. + /// Test result for pass/Fail criteria used during the test run. + /// Number of virtual users, for which test has been run. + /// Display name of a testRun. + /// Associated test Id. + /// The test run description. + /// The test run status. + /// The test run start DateTime(RFC 3339 literal format). + /// The test run end DateTime(RFC 3339 literal format). + /// Test run initiated time. + /// Portal url. + /// Test run duration in milliseconds. + /// Virtual user hours consumed by the test run. + /// Subnet ID on which the load test instances should run. + /// Type of test. + /// Request data collection level for test run. + /// Enable or disable debug level logging. True if debug logs are enabled for the test run. False otherwise. + /// Inject load test engines without deploying public IP for outbound access. + /// The type of the entity that created the test run. (E.x. User, ScheduleTrigger, etc). + /// The URI pointing to the entity that created the test run. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal LoadTestRun(string testRunId, PassFailCriteria passFailCriteria, AutoStopCriteria autoStopCriteria, IDictionary secrets, TestCertificate certificate, IDictionary environmentVariables, IReadOnlyList errorDetails, IReadOnlyDictionary testRunStatistics, IReadOnlyDictionary regionalStatistics, LoadTestConfiguration loadTestConfiguration, TestRunArtifacts testArtifacts, PassFailTestResult? testResult, int? virtualUsers, string displayName, string testId, string description, TestRunStatus? status, DateTimeOffset? startDateTime, DateTimeOffset? endDateTime, DateTimeOffset? executedDateTime, Uri portalUri, long? duration, double? virtualUserHours, string subnetId, LoadTestKind? kind, RequestDataLevel? requestDataLevel, bool? debugLogsEnabled, bool? publicIpDisabled, CreatedByType? createdByType, Uri createdByUri, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + { + TestRunId = testRunId; + PassFailCriteria = passFailCriteria; + AutoStopCriteria = autoStopCriteria; + Secrets = secrets; + Certificate = certificate; + EnvironmentVariables = environmentVariables; + ErrorDetails = errorDetails; + TestRunStatistics = testRunStatistics; + RegionalStatistics = regionalStatistics; + LoadTestConfiguration = loadTestConfiguration; + TestArtifacts = testArtifacts; + TestResult = testResult; + VirtualUsers = virtualUsers; + DisplayName = displayName; + TestId = testId; + Description = description; + Status = status; + StartDateTime = startDateTime; + EndDateTime = endDateTime; + ExecutedDateTime = executedDateTime; + PortalUri = portalUri; + Duration = duration; + VirtualUserHours = virtualUserHours; + SubnetId = subnetId; + Kind = kind; + RequestDataLevel = requestDataLevel; + DebugLogsEnabled = debugLogsEnabled; + PublicIpDisabled = publicIpDisabled; + CreatedByType = createdByType; + CreatedByUri = createdByUri; + CreatedDateTime = createdDateTime; + CreatedBy = createdBy; + LastModifiedDateTime = lastModifiedDateTime; + LastModifiedBy = lastModifiedBy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + public string TestRunId { get; } + /// Pass fail criteria for a test. + public PassFailCriteria PassFailCriteria { get; set; } + /// Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. + public AutoStopCriteria AutoStopCriteria { get; set; } + /// + /// Secrets can be stored in an Azure Key Vault or any other secret store. If the + /// secret is stored in an Azure Key Vault, the value should be the secret + /// identifier and the type should be AKV_SECRET_URI. If the secret is stored + /// elsewhere, the secret value should be provided directly and the type should be + /// SECRET_VALUE. + /// + public IDictionary Secrets { get; } + /// Certificates metadata. + public TestCertificate Certificate { get; set; } + /// Environment variables which are defined as a set of <name,value> pairs. + public IDictionary EnvironmentVariables { get; } + /// Error details if there is any failure in load test run. + public IReadOnlyList ErrorDetails { get; } + /// + /// Test run statistics. Key is the sampler name and value is the set of statistics for performance metrics like response time, throughput, etc. from the load test run. + /// The sampler name is the same as the name mentioned in the test script. + /// Sampler name "Total" represents the aggregated statistics of all the samplers. + /// + public IReadOnlyDictionary TestRunStatistics { get; } + /// + /// Regional statistics. Key is the Azure region name and value is the test run statistics. + /// The region name should of format accepted by ARM, and should be a region supported by Azure Load Testing. For example, East US should be passed as "eastus". + /// The region name must match one of the strings in the "Name" column returned from running the "az account list-locations -o table" Azure CLI command. + /// + public IReadOnlyDictionary RegionalStatistics { get; } + /// The load test configuration. + public LoadTestConfiguration LoadTestConfiguration { get; } + /// Collection of test run artifacts. + public TestRunArtifacts TestArtifacts { get; } + /// Test result for pass/Fail criteria used during the test run. + public PassFailTestResult? TestResult { get; } + /// Number of virtual users, for which test has been run. + public int? VirtualUsers { get; } + /// Display name of a testRun. + public string DisplayName { get; set; } + /// Associated test Id. + public string TestId { get; set; } + /// The test run description. + public string Description { get; set; } + /// The test run status. + public TestRunStatus? Status { get; } + /// The test run start DateTime(RFC 3339 literal format). + public DateTimeOffset? StartDateTime { get; } + /// The test run end DateTime(RFC 3339 literal format). + public DateTimeOffset? EndDateTime { get; } + /// Test run initiated time. + public DateTimeOffset? ExecutedDateTime { get; } + /// Portal url. + public Uri PortalUri { get; } + /// Test run duration in milliseconds. + public long? Duration { get; } + /// Virtual user hours consumed by the test run. + public double? VirtualUserHours { get; } + /// Subnet ID on which the load test instances should run. + public string SubnetId { get; } + /// Type of test. + public LoadTestKind? Kind { get; } + /// Request data collection level for test run. + public RequestDataLevel? RequestDataLevel { get; set; } + /// Enable or disable debug level logging. True if debug logs are enabled for the test run. False otherwise. + public bool? DebugLogsEnabled { get; set; } + /// Inject load test engines without deploying public IP for outbound access. + public bool? PublicIpDisabled { get; } + /// The type of the entity that created the test run. (E.x. User, ScheduleTrigger, etc). + public CreatedByType? CreatedByType { get; set; } + /// The URI pointing to the entity that created the test run. + public Uri CreatedByUri { get; } + /// The creation datetime(RFC 3339 literal format). + public DateTimeOffset? CreatedDateTime { get; } + /// The user that created. + public string CreatedBy { get; } + /// The last Modified datetime(RFC 3339 literal format). + public DateTimeOffset? LastModifiedDateTime { get; } + /// The user that last modified. + public string LastModifiedBy { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestRunClient.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestRunClient.cs new file mode 100644 index 000000000000..1de394e44344 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestRunClient.cs @@ -0,0 +1,2562 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + // Data plane generated client. + /// The LoadTestRun service client. + public partial class LoadTestRunClient + { + private static readonly string[] AuthorizationScopes = new string[] { "https://cnt-prod.loadtesting.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of LoadTestRunClient for mocking. + protected LoadTestRunClient() + { + } + + /// Initializes a new instance of LoadTestRunClient. + /// The to use. + /// A credential used to authenticate to an Azure Service. + /// or is null. + public LoadTestRunClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new AzureDeveloperLoadTestingClientOptions()) + { + } + + /// Initializes a new instance of LoadTestRunClient. + /// The to use. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public LoadTestRunClient(Uri endpoint, TokenCredential credential, AzureDeveloperLoadTestingClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new AzureDeveloperLoadTestingClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _tokenCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier()); + _endpoint = endpoint; + _apiVersion = options.Version; + } + + /// + /// [Protocol Method] Create and start a new test run with the given test run Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The content to send as the body of the request. + /// + /// Existing test run identifier that should be rerun, if this is provided, the + /// test will run with the JMX file, configuration and app components from the + /// existing test run. You can override the configuration values for new test run + /// in the request body. + /// + /// 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. + internal virtual async Task CreateOrUpdateTestRunAsync(string testRunId, RequestContent content, string oldTestRunId = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateTestRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTestRunRequest(testRunId, content, oldTestRunId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create and start a new test run with the given test run Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The content to send as the body of the request. + /// + /// Existing test run identifier that should be rerun, if this is provided, the + /// test will run with the JMX file, configuration and app components from the + /// existing test run. You can override the configuration values for new test run + /// in the request body. + /// + /// 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. + internal virtual Response CreateOrUpdateTestRun(string testRunId, RequestContent content, string oldTestRunId = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateTestRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTestRunRequest(testRunId, content, oldTestRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Add an app component to a test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// + /// Unique Id for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// 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 CreateOrUpdateAppComponentsAsync(string testRunId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateAppComponents"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateAppComponentsRequest(testRunId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Add an app component to a test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// + /// Unique Id for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// 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 CreateOrUpdateAppComponents(string testRunId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateAppComponents"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateAppComponentsRequest(testRunId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Configure server metrics for a test run + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// + /// Unique Id for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// 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 CreateOrUpdateServerMetricsConfigAsync(string testRunId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateServerMetricsConfig"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateServerMetricsConfigRequest(testRunId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Configure server metrics for a test run + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// + /// Unique Id for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// 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 CreateOrUpdateServerMetricsConfig(string testRunId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateServerMetricsConfig"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateServerMetricsConfigRequest(testRunId, 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 an existing load test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 DeleteTestRunAsync(string testRunId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.DeleteTestRun"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestRunRequest(testRunId, 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 an existing load test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 DeleteTestRun(string testRunId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.DeleteTestRun"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestRunRequest(testRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get associated app component (collection of azure resources) for the given test + /// run. + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAppComponentsAsync(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAppComponentsAsync(testRunId, context).ConfigureAwait(false); + return Response.FromValue(TestRunAppComponents.FromResponse(response), response); + } + + /// + /// Get associated app component (collection of azure resources) for the given test + /// run. + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetAppComponents(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAppComponents(testRunId, context); + return Response.FromValue(TestRunAppComponents.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get associated app component (collection of azure resources) for the given test + /// run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// 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 GetAppComponentsAsync(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetAppComponents"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAppComponentsRequest(testRunId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get associated app component (collection of azure resources) for the given test + /// run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// 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 GetAppComponents(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetAppComponents"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAppComponentsRequest(testRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get associated server metrics configuration for the given test run. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetServerMetricsConfigAsync(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetServerMetricsConfigAsync(testRunId, context).ConfigureAwait(false); + return Response.FromValue(TestRunServerMetricsConfiguration.FromResponse(response), response); + } + + /// Get associated server metrics configuration for the given test run. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetServerMetricsConfig(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetServerMetricsConfig(testRunId, context); + return Response.FromValue(TestRunServerMetricsConfiguration.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get associated server metrics configuration for the given test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// 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 GetServerMetricsConfigAsync(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetServerMetricsConfig"); + scope.Start(); + try + { + using HttpMessage message = CreateGetServerMetricsConfigRequest(testRunId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get associated server metrics configuration for the given test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// 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 GetServerMetricsConfig(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetServerMetricsConfig"); + scope.Start(); + try + { + using HttpMessage message = CreateGetServerMetricsConfigRequest(testRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get test run details by test run Id. + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetTestRunAsync(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetTestRunAsync(testRunId, context).ConfigureAwait(false); + return Response.FromValue(LoadTestRun.FromResponse(response), response); + } + + /// Get test run details by test run Id. + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetTestRun(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetTestRun(testRunId, context); + return Response.FromValue(LoadTestRun.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get test run details by test run Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 GetTestRunAsync(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRun"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestRunRequest(testRunId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get test run details by test run Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 GetTestRun(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRun"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestRunRequest(testRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get test run file by file name. + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> GetTestRunFileAsync(string testRunId, string fileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetTestRunFileAsync(testRunId, fileName, context).ConfigureAwait(false); + return Response.FromValue(TestRunFileInfo.FromResponse(response), response); + } + + /// Get test run file by file name. + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response GetTestRunFile(string testRunId, string fileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetTestRunFile(testRunId, fileName, context); + return Response.FromValue(TestRunFileInfo.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get test run file by file name. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetTestRunFileAsync(string testRunId, string fileName, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRunFile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestRunFileRequest(testRunId, fileName, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get test run file by file name. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual Response GetTestRunFile(string testRunId, string fileName, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRunFile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestRunFileRequest(testRunId, fileName, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List the metric definitions for a load test run. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Metric namespace to query metric definitions for. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetMetricDefinitionsAsync(string testRunId, string metricNamespace, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetMetricDefinitionsAsync(testRunId, metricNamespace, context).ConfigureAwait(false); + return Response.FromValue(MetricDefinitions.FromResponse(response), response); + } + + /// List the metric definitions for a load test run. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Metric namespace to query metric definitions for. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetMetricDefinitions(string testRunId, string metricNamespace, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetMetricDefinitions(testRunId, metricNamespace, context); + return Response.FromValue(MetricDefinitions.FromResponse(response), response); + } + + /// + /// [Protocol Method] List the metric definitions for a load test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Metric namespace to query metric definitions for. + /// 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 GetMetricDefinitionsAsync(string testRunId, string metricNamespace, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricDefinitions"); + scope.Start(); + try + { + using HttpMessage message = CreateGetMetricDefinitionsRequest(testRunId, metricNamespace, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] List the metric definitions for a load test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Metric namespace to query metric definitions for. + /// 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 GetMetricDefinitions(string testRunId, string metricNamespace, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricDefinitions"); + scope.Start(); + try + { + using HttpMessage message = CreateGetMetricDefinitionsRequest(testRunId, metricNamespace, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List the metric namespaces for a load test run. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetMetricNamespacesAsync(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetMetricNamespacesAsync(testRunId, context).ConfigureAwait(false); + return Response.FromValue(MetricNamespaces.FromResponse(response), response); + } + + /// List the metric namespaces for a load test run. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetMetricNamespaces(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetMetricNamespaces(testRunId, context); + return Response.FromValue(MetricNamespaces.FromResponse(response), response); + } + + /// + /// [Protocol Method] List the metric namespaces for a load test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// 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 GetMetricNamespacesAsync(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricNamespaces"); + scope.Start(); + try + { + using HttpMessage message = CreateGetMetricNamespacesRequest(testRunId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] List the metric namespaces for a load test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// 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 GetMetricNamespaces(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricNamespaces"); + scope.Start(); + try + { + using HttpMessage message = CreateGetMetricNamespacesRequest(testRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Stop test run by test run Id. + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> StopTestRunAsync(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await StopTestRunAsync(testRunId, context).ConfigureAwait(false); + return Response.FromValue(LoadTestRun.FromResponse(response), response); + } + + /// Stop test run by test run Id. + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response StopTestRun(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = StopTestRun(testRunId, context); + return Response.FromValue(LoadTestRun.FromResponse(response), response); + } + + /// + /// [Protocol Method] Stop test run by test run Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 StopTestRunAsync(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.StopTestRun"); + scope.Start(); + try + { + using HttpMessage message = CreateStopTestRunRequest(testRunId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Stop test run by test run Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 StopTestRun(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.StopTestRun"); + scope.Start(); + try + { + using HttpMessage message = CreateStopTestRunRequest(testRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create and start a new test profile run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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. + internal virtual async Task CreateOrUpdateTestProfileRunAsync(string testProfileRunId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateTestProfileRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTestProfileRunRequest(testProfileRunId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create and start a new test profile run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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. + internal virtual Response CreateOrUpdateTestProfileRun(string testProfileRunId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateTestProfileRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTestProfileRunRequest(testProfileRunId, 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 an existing load test profile run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 DeleteTestProfileRunAsync(string testProfileRunId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.DeleteTestProfileRun"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestProfileRunRequest(testProfileRunId, 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 an existing load test profile run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 DeleteTestProfileRun(string testProfileRunId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.DeleteTestProfileRun"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestProfileRunRequest(testProfileRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get test profile run details. + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Get test profile run details by test profile run Id. + public virtual async Task> GetTestProfileRunAsync(string testProfileRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetTestProfileRunAsync(testProfileRunId, context).ConfigureAwait(false); + return Response.FromValue(TestProfileRun.FromResponse(response), response); + } + + /// Get test profile run details. + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Get test profile run details by test profile run Id. + public virtual Response GetTestProfileRun(string testProfileRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetTestProfileRun(testProfileRunId, context); + return Response.FromValue(TestProfileRun.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get test profile run details. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 GetTestProfileRunAsync(string testProfileRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestProfileRun"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestProfileRunRequest(testProfileRunId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get test profile run details. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 GetTestProfileRun(string testProfileRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestProfileRun"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestProfileRunRequest(testProfileRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Stop test profile run. + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Stop test profile run for the given test profile run Id. + public virtual async Task> StopTestProfileRunAsync(string testProfileRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await StopTestProfileRunAsync(testProfileRunId, context).ConfigureAwait(false); + return Response.FromValue(TestProfileRun.FromResponse(response), response); + } + + /// Stop test profile run. + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Stop test profile run for the given test profile run Id. + public virtual Response StopTestProfileRun(string testProfileRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = StopTestProfileRun(testProfileRunId, context); + return Response.FromValue(TestProfileRun.FromResponse(response), response); + } + + /// + /// [Protocol Method] Stop test profile run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 StopTestProfileRunAsync(string testProfileRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.StopTestProfileRun"); + scope.Start(); + try + { + using HttpMessage message = CreateStopTestProfileRunRequest(testProfileRunId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Stop test profile run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// 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 StopTestProfileRun(string testProfileRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.StopTestProfileRun"); + scope.Start(); + try + { + using HttpMessage message = CreateStopTestProfileRunRequest(testProfileRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List the dimension values for the given metric dimension name. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Dimension name. + /// Metric name. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. + /// The cancellation token to use. + /// , , , or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual AsyncPageable GetMetricDimensionValuesAsync(string testRunId, string name, string metricname, string metricNamespace, string timespan, TimeGrain? interval = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(metricname, nameof(metricname)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(timespan, nameof(timespan)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMetricDimensionValuesRequest(testRunId, name, metricname, metricNamespace, timespan, interval?.ToString(), context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMetricDimensionValuesNextPageRequest(nextLink, testRunId, name, metricname, metricNamespace, timespan, interval?.ToString(), context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => e.GetString(), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetMetricDimensionValues", "value", "nextLink", context); + } + + /// List the dimension values for the given metric dimension name. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Dimension name. + /// Metric name. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. + /// The cancellation token to use. + /// , , , or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Pageable GetMetricDimensionValues(string testRunId, string name, string metricname, string metricNamespace, string timespan, TimeGrain? interval = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(metricname, nameof(metricname)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(timespan, nameof(timespan)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMetricDimensionValuesRequest(testRunId, name, metricname, metricNamespace, timespan, interval?.ToString(), context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMetricDimensionValuesNextPageRequest(nextLink, testRunId, name, metricname, metricNamespace, timespan, interval?.ToString(), context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => e.GetString(), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetMetricDimensionValues", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List the dimension values for the given metric dimension name. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Dimension name. + /// Metric name. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. Allowed values: "PT5S" | "PT10S" | "PT1M" | "PT5M" | "PT1H". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , , , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The 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 GetMetricDimensionValuesAsync(string testRunId, string name, string metricname, string metricNamespace, string timespan, string interval, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(metricname, nameof(metricname)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(timespan, nameof(timespan)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMetricDimensionValuesRequest(testRunId, name, metricname, metricNamespace, timespan, interval, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMetricDimensionValuesNextPageRequest(nextLink, testRunId, name, metricname, metricNamespace, timespan, interval, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetMetricDimensionValues", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List the dimension values for the given metric dimension name. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Dimension name. + /// Metric name. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. Allowed values: "PT5S" | "PT10S" | "PT1M" | "PT5M" | "PT1H". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , , , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The 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 GetMetricDimensionValues(string testRunId, string name, string metricname, string metricNamespace, string timespan, string interval, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(metricname, nameof(metricname)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(timespan, nameof(timespan)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMetricDimensionValuesRequest(testRunId, name, metricname, metricNamespace, timespan, interval, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMetricDimensionValuesNextPageRequest(nextLink, testRunId, name, metricname, metricNamespace, timespan, interval, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetMetricDimensionValues", "value", "nextLink", context); + } + + /// List the metric values for a load test run. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Metric name. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// Metric dimension filter. + /// The aggregation. + /// The interval (i.e. timegrain) of the query. + /// The cancellation token to use. + /// , , or is null. + /// is an empty string, and was expected to be non-empty. + public virtual AsyncPageable GetMetricsAsync(string testRunId, string metricname, string metricNamespace, string timespan, MetricsFilters body = null, string aggregation = null, TimeGrain? interval = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(metricname, nameof(metricname)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(timespan, nameof(timespan)); + + RequestContent content = body?.ToRequestContent(); + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMetricsRequest(testRunId, metricname, metricNamespace, timespan, content, aggregation, interval?.ToString(), context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMetricsNextPageRequest(nextLink, testRunId, metricname, metricNamespace, timespan, content, aggregation, interval?.ToString(), context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => TimeSeriesElement.DeserializeTimeSeriesElement(e), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetMetrics", "value", "nextLink", context); + } + + /// List the metric values for a load test run. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Metric name. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// Metric dimension filter. + /// The aggregation. + /// The interval (i.e. timegrain) of the query. + /// The cancellation token to use. + /// , , or is null. + /// is an empty string, and was expected to be non-empty. + public virtual Pageable GetMetrics(string testRunId, string metricname, string metricNamespace, string timespan, MetricsFilters body = null, string aggregation = null, TimeGrain? interval = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(metricname, nameof(metricname)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(timespan, nameof(timespan)); + + RequestContent content = body?.ToRequestContent(); + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMetricsRequest(testRunId, metricname, metricNamespace, timespan, content, aggregation, interval?.ToString(), context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMetricsNextPageRequest(nextLink, testRunId, metricname, metricNamespace, timespan, content, aggregation, interval?.ToString(), context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => TimeSeriesElement.DeserializeTimeSeriesElement(e), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetMetrics", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List the metric values for a load test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Metric name. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The content to send as the body of the request. + /// The aggregation. + /// The interval (i.e. timegrain) of the query. Allowed values: "PT5S" | "PT10S" | "PT1M" | "PT5M" | "PT1H". + /// 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 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 GetMetricsAsync(string testRunId, string metricname, string metricNamespace, string timespan, RequestContent content, string aggregation = null, string interval = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(metricname, nameof(metricname)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(timespan, nameof(timespan)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMetricsRequest(testRunId, metricname, metricNamespace, timespan, content, aggregation, interval, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMetricsNextPageRequest(nextLink, testRunId, metricname, metricNamespace, timespan, content, aggregation, interval, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetMetrics", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List the metric values for a load test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Metric name. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The content to send as the body of the request. + /// The aggregation. + /// The interval (i.e. timegrain) of the query. Allowed values: "PT5S" | "PT10S" | "PT1M" | "PT5M" | "PT1H". + /// 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 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 GetMetrics(string testRunId, string metricname, string metricNamespace, string timespan, RequestContent content, string aggregation = null, string interval = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(metricname, nameof(metricname)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(timespan, nameof(timespan)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMetricsRequest(testRunId, metricname, metricNamespace, timespan, content, aggregation, interval, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMetricsNextPageRequest(nextLink, testRunId, metricname, metricNamespace, timespan, content, aggregation, interval, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetMetrics", "value", "nextLink", context); + } + + /// Get all test runs for the given filters. + /// + /// Sort on the supported fields in (field asc/desc) format. eg: executedDateTime + /// asc. Supported fields - executedDateTime + /// + /// + /// Prefix based, case sensitive search on searchable fields - description, + /// executedUser. For example, to search for a test run, with description 500 VUs, + /// the search parameter can be 500. + /// + /// Unique name of an existing load test. + /// Start DateTime(RFC 3339 literal format) of test-run execution time filter range. + /// End DateTime(RFC 3339 literal format) of test-run execution time filter range. + /// Comma separated list of test run status. + /// Number of results in response. + /// Comma separated list of type of entities that have created the test run. + /// The cancellation token to use. + public virtual AsyncPageable GetTestRunsAsync(string orderby = null, string search = null, string testId = null, DateTimeOffset? executionFrom = null, DateTimeOffset? executionTo = null, string status = null, int? maxpagesize = null, IEnumerable createdByTypes = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestRunsRequest(orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, createdByTypes, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestRunsNextPageRequest(nextLink, orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, createdByTypes, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => LoadTestRun.DeserializeLoadTestRun(e), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestRuns", "value", "nextLink", maxpagesize, context); + } + + /// Get all test runs for the given filters. + /// + /// Sort on the supported fields in (field asc/desc) format. eg: executedDateTime + /// asc. Supported fields - executedDateTime + /// + /// + /// Prefix based, case sensitive search on searchable fields - description, + /// executedUser. For example, to search for a test run, with description 500 VUs, + /// the search parameter can be 500. + /// + /// Unique name of an existing load test. + /// Start DateTime(RFC 3339 literal format) of test-run execution time filter range. + /// End DateTime(RFC 3339 literal format) of test-run execution time filter range. + /// Comma separated list of test run status. + /// Number of results in response. + /// Comma separated list of type of entities that have created the test run. + /// The cancellation token to use. + public virtual Pageable GetTestRuns(string orderby = null, string search = null, string testId = null, DateTimeOffset? executionFrom = null, DateTimeOffset? executionTo = null, string status = null, int? maxpagesize = null, IEnumerable createdByTypes = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestRunsRequest(orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, createdByTypes, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestRunsNextPageRequest(nextLink, orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, createdByTypes, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => LoadTestRun.DeserializeLoadTestRun(e), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestRuns", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] Get all test runs for the given filters. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// + /// Sort on the supported fields in (field asc/desc) format. eg: executedDateTime + /// asc. Supported fields - executedDateTime + /// + /// + /// Prefix based, case sensitive search on searchable fields - description, + /// executedUser. For example, to search for a test run, with description 500 VUs, + /// the search parameter can be 500. + /// + /// Unique name of an existing load test. + /// Start DateTime(RFC 3339 literal format) of test-run execution time filter range. + /// End DateTime(RFC 3339 literal format) of test-run execution time filter range. + /// Comma separated list of test run status. + /// Number of results in response. + /// Comma separated list of type of entities that have created the test run. + /// 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 GetTestRunsAsync(string orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, int? maxpagesize, IEnumerable createdByTypes, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestRunsRequest(orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, createdByTypes, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestRunsNextPageRequest(nextLink, orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, createdByTypes, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestRuns", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] Get all test runs for the given filters. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// + /// Sort on the supported fields in (field asc/desc) format. eg: executedDateTime + /// asc. Supported fields - executedDateTime + /// + /// + /// Prefix based, case sensitive search on searchable fields - description, + /// executedUser. For example, to search for a test run, with description 500 VUs, + /// the search parameter can be 500. + /// + /// Unique name of an existing load test. + /// Start DateTime(RFC 3339 literal format) of test-run execution time filter range. + /// End DateTime(RFC 3339 literal format) of test-run execution time filter range. + /// Comma separated list of test run status. + /// Number of results in response. + /// Comma separated list of type of entities that have created the test run. + /// 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 GetTestRuns(string orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, int? maxpagesize, IEnumerable createdByTypes, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestRunsRequest(orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, createdByTypes, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestRunsNextPageRequest(nextLink, orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, createdByTypes, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestRuns", "value", "nextLink", maxpagesize, context); + } + + /// List test profile runs. + /// Maximum number of results to include in a single response. + /// Minimum Start DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Maximum Start DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Minimum End DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Maximum End DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Start DateTime(RFC 3339 literal format) of the created time range to filter test profile runs. + /// End DateTime(RFC 3339 literal format) of the created time range to filter test profile runs. + /// Comma separated list of IDs of the test profile runs to filter. + /// Comma separated IDs of the test profiles which should be associated with the test profile runs to fetch. + /// Comma separated list of Statuses of the test profile runs to filter. + /// The cancellation token to use. + /// Get all test profile runs for the given filters. + public virtual AsyncPageable GetTestProfileRunsAsync(int? maxpagesize = null, DateTimeOffset? minStartDateTime = null, DateTimeOffset? maxStartDateTime = null, DateTimeOffset? minEndDateTime = null, DateTimeOffset? maxEndDateTime = null, DateTimeOffset? createdDateStartTime = null, DateTimeOffset? createdDateEndTime = null, IEnumerable testProfileRunIds = null, IEnumerable testProfileIds = null, IEnumerable statuses = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestProfileRunsRequest(pageSizeHint, minStartDateTime, maxStartDateTime, minEndDateTime, maxEndDateTime, createdDateStartTime, createdDateEndTime, testProfileRunIds, testProfileIds, statuses, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestProfileRunsNextPageRequest(nextLink, pageSizeHint, minStartDateTime, maxStartDateTime, minEndDateTime, maxEndDateTime, createdDateStartTime, createdDateEndTime, testProfileRunIds, testProfileIds, statuses, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => TestProfileRun.DeserializeTestProfileRun(e), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestProfileRuns", "value", "nextLink", maxpagesize, context); + } + + /// List test profile runs. + /// Maximum number of results to include in a single response. + /// Minimum Start DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Maximum Start DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Minimum End DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Maximum End DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Start DateTime(RFC 3339 literal format) of the created time range to filter test profile runs. + /// End DateTime(RFC 3339 literal format) of the created time range to filter test profile runs. + /// Comma separated list of IDs of the test profile runs to filter. + /// Comma separated IDs of the test profiles which should be associated with the test profile runs to fetch. + /// Comma separated list of Statuses of the test profile runs to filter. + /// The cancellation token to use. + /// Get all test profile runs for the given filters. + public virtual Pageable GetTestProfileRuns(int? maxpagesize = null, DateTimeOffset? minStartDateTime = null, DateTimeOffset? maxStartDateTime = null, DateTimeOffset? minEndDateTime = null, DateTimeOffset? maxEndDateTime = null, DateTimeOffset? createdDateStartTime = null, DateTimeOffset? createdDateEndTime = null, IEnumerable testProfileRunIds = null, IEnumerable testProfileIds = null, IEnumerable statuses = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestProfileRunsRequest(pageSizeHint, minStartDateTime, maxStartDateTime, minEndDateTime, maxEndDateTime, createdDateStartTime, createdDateEndTime, testProfileRunIds, testProfileIds, statuses, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestProfileRunsNextPageRequest(nextLink, pageSizeHint, minStartDateTime, maxStartDateTime, minEndDateTime, maxEndDateTime, createdDateStartTime, createdDateEndTime, testProfileRunIds, testProfileIds, statuses, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => TestProfileRun.DeserializeTestProfileRun(e), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestProfileRuns", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] List test profile runs. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Maximum number of results to include in a single response. + /// Minimum Start DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Maximum Start DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Minimum End DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Maximum End DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Start DateTime(RFC 3339 literal format) of the created time range to filter test profile runs. + /// End DateTime(RFC 3339 literal format) of the created time range to filter test profile runs. + /// Comma separated list of IDs of the test profile runs to filter. + /// Comma separated IDs of the test profiles which should be associated with the test profile runs to fetch. + /// Comma separated list of Statuses of the test profile runs to filter. + /// 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 GetTestProfileRunsAsync(int? maxpagesize, DateTimeOffset? minStartDateTime, DateTimeOffset? maxStartDateTime, DateTimeOffset? minEndDateTime, DateTimeOffset? maxEndDateTime, DateTimeOffset? createdDateStartTime, DateTimeOffset? createdDateEndTime, IEnumerable testProfileRunIds, IEnumerable testProfileIds, IEnumerable statuses, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestProfileRunsRequest(pageSizeHint, minStartDateTime, maxStartDateTime, minEndDateTime, maxEndDateTime, createdDateStartTime, createdDateEndTime, testProfileRunIds, testProfileIds, statuses, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestProfileRunsNextPageRequest(nextLink, pageSizeHint, minStartDateTime, maxStartDateTime, minEndDateTime, maxEndDateTime, createdDateStartTime, createdDateEndTime, testProfileRunIds, testProfileIds, statuses, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestProfileRuns", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] List test profile runs. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Maximum number of results to include in a single response. + /// Minimum Start DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Maximum Start DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Minimum End DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Maximum End DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Start DateTime(RFC 3339 literal format) of the created time range to filter test profile runs. + /// End DateTime(RFC 3339 literal format) of the created time range to filter test profile runs. + /// Comma separated list of IDs of the test profile runs to filter. + /// Comma separated IDs of the test profiles which should be associated with the test profile runs to fetch. + /// Comma separated list of Statuses of the test profile runs to filter. + /// 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 GetTestProfileRuns(int? maxpagesize, DateTimeOffset? minStartDateTime, DateTimeOffset? maxStartDateTime, DateTimeOffset? minEndDateTime, DateTimeOffset? maxEndDateTime, DateTimeOffset? createdDateStartTime, DateTimeOffset? createdDateEndTime, IEnumerable testProfileRunIds, IEnumerable testProfileIds, IEnumerable statuses, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestProfileRunsRequest(pageSizeHint, minStartDateTime, maxStartDateTime, minEndDateTime, maxEndDateTime, createdDateStartTime, createdDateEndTime, testProfileRunIds, testProfileIds, statuses, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestProfileRunsNextPageRequest(nextLink, pageSizeHint, minStartDateTime, maxStartDateTime, minEndDateTime, maxEndDateTime, createdDateStartTime, createdDateEndTime, testProfileRunIds, testProfileIds, statuses, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestProfileRuns", "value", "nextLink", maxpagesize, context); + } + + internal HttpMessage CreateCreateOrUpdateTestRunRequest(string testRunId, RequestContent content, string oldTestRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendQuery("api-version", _apiVersion, true); + if (oldTestRunId != null) + { + uri.AppendQuery("oldTestRunId", oldTestRunId, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateCreateOrUpdateAppComponentsRequest(string testRunId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/app-components", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateCreateOrUpdateServerMetricsConfigRequest(string testRunId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/server-metrics-config", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteTestRunRequest(string testRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetAppComponentsRequest(string testRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/app-components", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetServerMetricsConfigRequest(string testRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/server-metrics-config", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestRunRequest(string testRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestRunFileRequest(string testRunId, string fileName, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/files/", false); + uri.AppendPath(fileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMetricDimensionValuesRequest(string testRunId, string name, string metricname, string metricNamespace, string timespan, string interval, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/metric-dimensions/", false); + uri.AppendPath(name, true); + uri.AppendPath("/values", false); + uri.AppendQuery("metricname", metricname, true); + uri.AppendQuery("metricNamespace", metricNamespace, true); + uri.AppendQuery("timespan", timespan, true); + uri.AppendQuery("api-version", _apiVersion, true); + if (interval != null) + { + uri.AppendQuery("interval", interval, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMetricDefinitionsRequest(string testRunId, string metricNamespace, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/metric-definitions", false); + uri.AppendQuery("metricNamespace", metricNamespace, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMetricNamespacesRequest(string testRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/metric-namespaces", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMetricsRequest(string testRunId, string metricname, string metricNamespace, string timespan, RequestContent content, string aggregation, string interval, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/metrics", false); + uri.AppendQuery("metricname", metricname, true); + uri.AppendQuery("metricNamespace", metricNamespace, true); + uri.AppendQuery("timespan", timespan, true); + uri.AppendQuery("api-version", _apiVersion, true); + if (aggregation != null) + { + uri.AppendQuery("aggregation", aggregation, true); + } + if (interval != null) + { + uri.AppendQuery("interval", interval, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetTestRunsRequest(string orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, int? maxpagesize, IEnumerable createdByTypes, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (orderby != null) + { + uri.AppendQuery("orderby", orderby, true); + } + if (search != null) + { + uri.AppendQuery("search", search, true); + } + if (testId != null) + { + uri.AppendQuery("testId", testId, true); + } + if (executionFrom != null) + { + uri.AppendQuery("executionFrom", executionFrom.Value, "O", true); + } + if (executionTo != null) + { + uri.AppendQuery("executionTo", executionTo.Value, "O", true); + } + if (status != null) + { + uri.AppendQuery("status", status, true); + } + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } + if (createdByTypes != null && !(createdByTypes is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) + { + uri.AppendQueryDelimited("createdByTypes", createdByTypes, ",", true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateStopTestRunRequest(string testRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath(":stop", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateTestProfileRunRequest(string testProfileRunId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-profile-runs/", false); + uri.AppendPath(testProfileRunId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteTestProfileRunRequest(string testProfileRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-profile-runs/", false); + uri.AppendPath(testProfileRunId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestProfileRunRequest(string testProfileRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-profile-runs/", false); + uri.AppendPath(testProfileRunId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestProfileRunsRequest(int? maxpagesize, DateTimeOffset? minStartDateTime, DateTimeOffset? maxStartDateTime, DateTimeOffset? minEndDateTime, DateTimeOffset? maxEndDateTime, DateTimeOffset? createdDateStartTime, DateTimeOffset? createdDateEndTime, IEnumerable testProfileRunIds, IEnumerable testProfileIds, IEnumerable statuses, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-profile-runs", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } + if (minStartDateTime != null) + { + uri.AppendQuery("minStartDateTime", minStartDateTime.Value, "O", true); + } + if (maxStartDateTime != null) + { + uri.AppendQuery("maxStartDateTime", maxStartDateTime.Value, "O", true); + } + if (minEndDateTime != null) + { + uri.AppendQuery("minEndDateTime", minEndDateTime.Value, "O", true); + } + if (maxEndDateTime != null) + { + uri.AppendQuery("maxEndDateTime", maxEndDateTime.Value, "O", true); + } + if (createdDateStartTime != null) + { + uri.AppendQuery("createdDateStartTime", createdDateStartTime.Value, "O", true); + } + if (createdDateEndTime != null) + { + uri.AppendQuery("createdDateEndTime", createdDateEndTime.Value, "O", true); + } + if (testProfileRunIds != null && !(testProfileRunIds is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) + { + uri.AppendQueryDelimited("testProfileRunIds", testProfileRunIds, ",", true); + } + if (testProfileIds != null && !(testProfileIds is ChangeTrackingList changeTrackingList0 && changeTrackingList0.IsUndefined)) + { + uri.AppendQueryDelimited("testProfileIds", testProfileIds, ",", true); + } + if (statuses != null && !(statuses is ChangeTrackingList changeTrackingList1 && changeTrackingList1.IsUndefined)) + { + uri.AppendQueryDelimited("statuses", statuses, ",", true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateStopTestProfileRunRequest(string testProfileRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-profile-runs/", false); + uri.AppendPath(testProfileRunId, true); + uri.AppendPath(":stop", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMetricDimensionValuesNextPageRequest(string nextLink, string testRunId, string name, string metricname, string metricNamespace, string timespan, string interval, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMetricsNextPageRequest(string nextLink, string testRunId, string metricname, string metricNamespace, string timespan, RequestContent content, string aggregation, string interval, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestRunsNextPageRequest(string nextLink, string orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, int? maxpagesize, IEnumerable createdByTypes, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestProfileRunsNextPageRequest(string nextLink, int? maxpagesize, DateTimeOffset? minStartDateTime, DateTimeOffset? maxStartDateTime, DateTimeOffset? minEndDateTime, DateTimeOffset? maxEndDateTime, DateTimeOffset? createdDateStartTime, DateTimeOffset? createdDateEndTime, IEnumerable testProfileRunIds, IEnumerable testProfileIds, IEnumerable statuses, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + 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 _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 }); + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestingAppComponent.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestingAppComponent.Serialization.cs new file mode 100644 index 000000000000..f96a81a46548 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestingAppComponent.Serialization.cs @@ -0,0 +1,213 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class LoadTestingAppComponent : 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(LoadTestingAppComponent)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("resourceId"u8); + writer.WriteStringValue(ResourceId); + } + writer.WritePropertyName("resourceName"u8); + writer.WriteStringValue(ResourceName); + writer.WritePropertyName("resourceType"u8); + writer.WriteStringValue(ResourceType); + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (options.Format != "W" && Optional.IsDefined(ResourceGroup)) + { + writer.WritePropertyName("resourceGroup"u8); + writer.WriteStringValue(ResourceGroup); + } + if (options.Format != "W" && Optional.IsDefined(SubscriptionId)) + { + writer.WritePropertyName("subscriptionId"u8); + writer.WriteStringValue(SubscriptionId); + } + if (Optional.IsDefined(Kind)) + { + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind); + } + 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 + } + } + } + + LoadTestingAppComponent 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(LoadTestingAppComponent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLoadTestingAppComponent(document.RootElement, options); + } + + internal static LoadTestingAppComponent DeserializeLoadTestingAppComponent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier resourceId = default; + string resourceName = default; + string resourceType = default; + string displayName = default; + string resourceGroup = default; + string subscriptionId = default; + string kind = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceId"u8)) + { + resourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("resourceName"u8)) + { + resourceName = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceType"u8)) + { + resourceType = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceGroup"u8)) + { + resourceGroup = property.Value.GetString(); + continue; + } + if (property.NameEquals("subscriptionId"u8)) + { + subscriptionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("kind"u8)) + { + kind = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new LoadTestingAppComponent( + resourceId, + resourceName, + resourceType, + displayName, + resourceGroup, + subscriptionId, + kind, + 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(LoadTestingAppComponent)} does not support writing '{options.Format}' format."); + } + } + + LoadTestingAppComponent 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 DeserializeLoadTestingAppComponent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LoadTestingAppComponent)} 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 LoadTestingAppComponent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeLoadTestingAppComponent(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestingAppComponent.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestingAppComponent.cs new file mode 100644 index 000000000000..ecd42ad181a8 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestingAppComponent.cs @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + /// An Azure resource object (Refer azure generic resource model :https://learn.microsoft.com/en-us/rest/api/resources/resources/get-by-id#genericresource). + public partial class LoadTestingAppComponent + { + /// + /// 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 . + /// Azure resource name, required while creating the app component. + /// Azure resource type, required while creating the app component. + /// or is null. + public LoadTestingAppComponent(string resourceName, string resourceType) + { + Argument.AssertNotNull(resourceName, nameof(resourceName)); + Argument.AssertNotNull(resourceType, nameof(resourceType)); + + ResourceName = resourceName; + ResourceType = resourceType; + } + + /// Initializes a new instance of . + /// fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + /// Azure resource name, required while creating the app component. + /// Azure resource type, required while creating the app component. + /// Azure resource display name. + /// Resource group name of the Azure resource. + /// Subscription Id of the Azure resource. + /// Kind of Azure resource type. + /// Keeps track of any properties unknown to the library. + internal LoadTestingAppComponent(ResourceIdentifier resourceId, string resourceName, string resourceType, string displayName, string resourceGroup, string subscriptionId, string kind, IDictionary serializedAdditionalRawData) + { + ResourceId = resourceId; + ResourceName = resourceName; + ResourceType = resourceType; + DisplayName = displayName; + ResourceGroup = resourceGroup; + SubscriptionId = subscriptionId; + Kind = kind; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal LoadTestingAppComponent() + { + } + + /// fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + public ResourceIdentifier ResourceId { get; } + /// Azure resource name, required while creating the app component. + public string ResourceName { get; set; } + /// Azure resource type, required while creating the app component. + public string ResourceType { get; set; } + /// Azure resource display name. + public string DisplayName { get; set; } + /// Resource group name of the Azure resource. + public string ResourceGroup { get; } + /// Subscription Id of the Azure resource. + public string SubscriptionId { get; } + /// Kind of Azure resource type. + public string Kind { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestingFileType.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestingFileType.cs new file mode 100644 index 000000000000..78387b0fae18 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestingFileType.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Types of file supported. + public readonly partial struct LoadTestingFileType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public LoadTestingFileType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string JmxFileValue = "JMX_FILE"; + private const string UserPropertiesValue = "USER_PROPERTIES"; + private const string AdditionalArtifactsValue = "ADDITIONAL_ARTIFACTS"; + private const string ZippedArtifactsValue = "ZIPPED_ARTIFACTS"; + private const string UrlTestConfigValue = "URL_TEST_CONFIG"; + private const string TestScriptValue = "TEST_SCRIPT"; + + /// If the file is a JMX script. + public static LoadTestingFileType JmxFile { get; } = new LoadTestingFileType(JmxFileValue); + /// If the file is a user properties file. + public static LoadTestingFileType UserProperties { get; } = new LoadTestingFileType(UserPropertiesValue); + /// If the file is not among any of the other supported file types. + public static LoadTestingFileType AdditionalArtifacts { get; } = new LoadTestingFileType(AdditionalArtifactsValue); + /// If the file is a compressed archive containing a collection of various artifacts or resources. + public static LoadTestingFileType ZippedArtifacts { get; } = new LoadTestingFileType(ZippedArtifactsValue); + /// If the file is a JSON config file to define the requests for a URL test. + public static LoadTestingFileType UrlTestConfig { get; } = new LoadTestingFileType(UrlTestConfigValue); + /// If the file is a test script. + public static LoadTestingFileType TestScript { get; } = new LoadTestingFileType(TestScriptValue); + /// Determines if two values are the same. + public static bool operator ==(LoadTestingFileType left, LoadTestingFileType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(LoadTestingFileType left, LoadTestingFileType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator LoadTestingFileType(string value) => new LoadTestingFileType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is LoadTestingFileType other && Equals(other); + /// + public bool Equals(LoadTestingFileType 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestingManagedIdentityType.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestingManagedIdentityType.cs new file mode 100644 index 000000000000..3919a0d3c86d --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestingManagedIdentityType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Managed identity type. + public readonly partial struct LoadTestingManagedIdentityType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public LoadTestingManagedIdentityType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SystemAssignedValue = "SystemAssigned"; + private const string UserAssignedValue = "UserAssigned"; + + /// System-assigned managed identity. + public static LoadTestingManagedIdentityType SystemAssigned { get; } = new LoadTestingManagedIdentityType(SystemAssignedValue); + /// User-assigned managed identity. + public static LoadTestingManagedIdentityType UserAssigned { get; } = new LoadTestingManagedIdentityType(UserAssignedValue); + /// Determines if two values are the same. + public static bool operator ==(LoadTestingManagedIdentityType left, LoadTestingManagedIdentityType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(LoadTestingManagedIdentityType left, LoadTestingManagedIdentityType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator LoadTestingManagedIdentityType(string value) => new LoadTestingManagedIdentityType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is LoadTestingManagedIdentityType other && Equals(other); + /// + public bool Equals(LoadTestingManagedIdentityType 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricAvailability.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricAvailability.Serialization.cs new file mode 100644 index 000000000000..5fb71e167bf6 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricAvailability.Serialization.cs @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class MetricAvailability : 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(MetricAvailability)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(TimeGrain)) + { + writer.WritePropertyName("timeGrain"u8); + writer.WriteStringValue(TimeGrain.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MetricAvailability 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(MetricAvailability)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricAvailability(document.RootElement, options); + } + + internal static MetricAvailability DeserializeMetricAvailability(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TimeGrain? timeGrain = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("timeGrain"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + timeGrain = new TimeGrain(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MetricAvailability(timeGrain, 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(MetricAvailability)} does not support writing '{options.Format}' format."); + } + } + + MetricAvailability 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 DeserializeMetricAvailability(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricAvailability)} 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 MetricAvailability FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMetricAvailability(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricAvailability.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricAvailability.cs new file mode 100644 index 000000000000..7634872e8667 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricAvailability.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Metric availability specifies the time grain (aggregation interval or frequency). + public partial class MetricAvailability + { + /// + /// 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 MetricAvailability() + { + } + + /// Initializes a new instance of . + /// + /// The time grain specifies the aggregation interval for the metric. Expressed as + /// a duration 'PT1M', 'PT1H', etc. + /// + /// Keeps track of any properties unknown to the library. + internal MetricAvailability(TimeGrain? timeGrain, IDictionary serializedAdditionalRawData) + { + TimeGrain = timeGrain; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// The time grain specifies the aggregation interval for the metric. Expressed as + /// a duration 'PT1M', 'PT1H', etc. + /// + public TimeGrain? TimeGrain { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricDefinition.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricDefinition.Serialization.cs new file mode 100644 index 000000000000..36725c36bc6d --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricDefinition.Serialization.cs @@ -0,0 +1,281 @@ +// 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.Developer.LoadTesting +{ + public partial class MetricDefinition : 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(MetricDefinition)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Dimensions)) + { + writer.WritePropertyName("dimensions"u8); + writer.WriteStartArray(); + foreach (var item in Dimensions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Namespace)) + { + writer.WritePropertyName("namespace"u8); + writer.WriteStringValue(Namespace); + } + if (Optional.IsDefined(PrimaryAggregationType)) + { + writer.WritePropertyName("primaryAggregationType"u8); + writer.WriteStringValue(PrimaryAggregationType.Value.ToString()); + } + if (Optional.IsCollectionDefined(SupportedAggregationTypes)) + { + writer.WritePropertyName("supportedAggregationTypes"u8); + writer.WriteStartArray(); + foreach (var item in SupportedAggregationTypes) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Unit)) + { + writer.WritePropertyName("unit"u8); + writer.WriteStringValue(Unit.Value.ToString()); + } + if (Optional.IsCollectionDefined(MetricAvailabilities)) + { + writer.WritePropertyName("metricAvailabilities"u8); + writer.WriteStartArray(); + foreach (var item in MetricAvailabilities) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MetricDefinition 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(MetricDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricDefinition(document.RootElement, options); + } + + internal static MetricDefinition DeserializeMetricDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList dimensions = default; + string description = default; + string name = default; + string @namespace = default; + AggregationType? primaryAggregationType = default; + IReadOnlyList supportedAggregationTypes = default; + MetricUnit? unit = default; + IReadOnlyList metricAvailabilities = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("dimensions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NameAndDescription.DeserializeNameAndDescription(item, options)); + } + dimensions = array; + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("namespace"u8)) + { + @namespace = property.Value.GetString(); + continue; + } + if (property.NameEquals("primaryAggregationType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + primaryAggregationType = new AggregationType(property.Value.GetString()); + continue; + } + if (property.NameEquals("supportedAggregationTypes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + supportedAggregationTypes = array; + continue; + } + if (property.NameEquals("unit"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + unit = new MetricUnit(property.Value.GetString()); + continue; + } + if (property.NameEquals("metricAvailabilities"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricAvailability.DeserializeMetricAvailability(item, options)); + } + metricAvailabilities = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MetricDefinition( + dimensions ?? new ChangeTrackingList(), + description, + name, + @namespace, + primaryAggregationType, + supportedAggregationTypes ?? new ChangeTrackingList(), + unit, + metricAvailabilities ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MetricDefinition)} does not support writing '{options.Format}' format."); + } + } + + MetricDefinition 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 DeserializeMetricDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricDefinition)} 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 MetricDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMetricDefinition(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricDefinition.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricDefinition.cs new file mode 100644 index 000000000000..7fb3baf52391 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricDefinition.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Metric definition. + public partial class MetricDefinition + { + /// + /// 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 MetricDefinition() + { + Dimensions = new ChangeTrackingList(); + SupportedAggregationTypes = new ChangeTrackingList(); + MetricAvailabilities = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// List of dimensions. + /// The metric description. + /// The metric name. + /// The namespace the metric belongs to. + /// The primary aggregation type value defining how to use the values for display. + /// The collection of what all aggregation types are supported. + /// The unit of the metric. + /// + /// Metric availability specifies the time grain (aggregation interval or + /// frequency). + /// + /// Keeps track of any properties unknown to the library. + internal MetricDefinition(IReadOnlyList dimensions, string description, string name, string @namespace, AggregationType? primaryAggregationType, IReadOnlyList supportedAggregationTypes, MetricUnit? unit, IReadOnlyList metricAvailabilities, IDictionary serializedAdditionalRawData) + { + Dimensions = dimensions; + Description = description; + Name = name; + Namespace = @namespace; + PrimaryAggregationType = primaryAggregationType; + SupportedAggregationTypes = supportedAggregationTypes; + Unit = unit; + MetricAvailabilities = metricAvailabilities; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// List of dimensions. + public IReadOnlyList Dimensions { get; } + /// The metric description. + public string Description { get; } + /// The metric name. + public string Name { get; } + /// The namespace the metric belongs to. + public string Namespace { get; } + /// The primary aggregation type value defining how to use the values for display. + public AggregationType? PrimaryAggregationType { get; } + /// The collection of what all aggregation types are supported. + public IReadOnlyList SupportedAggregationTypes { get; } + /// The unit of the metric. + public MetricUnit? Unit { get; } + /// + /// Metric availability specifies the time grain (aggregation interval or + /// frequency). + /// + public IReadOnlyList MetricAvailabilities { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricDefinitions.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricDefinitions.Serialization.cs new file mode 100644 index 000000000000..64984c2a284f --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricDefinitions.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class MetricDefinitions : 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(MetricDefinitions)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MetricDefinitions 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(MetricDefinitions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricDefinitions(document.RootElement, options); + } + + internal static MetricDefinitions DeserializeMetricDefinitions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricDefinition.DeserializeMetricDefinition(item, options)); + } + value = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MetricDefinitions(value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MetricDefinitions)} does not support writing '{options.Format}' format."); + } + } + + MetricDefinitions 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 DeserializeMetricDefinitions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricDefinitions)} 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 MetricDefinitions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMetricDefinitions(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricDefinitions.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricDefinitions.cs new file mode 100644 index 000000000000..a33557916200 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricDefinitions.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.Developer.LoadTesting +{ + /// Represents collection of metric definitions. + public partial class MetricDefinitions + { + /// + /// 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 values for the metric definitions. + /// is null. + internal MetricDefinitions(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// the values for the metric definitions. + /// Keeps track of any properties unknown to the library. + internal MetricDefinitions(IReadOnlyList value, IDictionary serializedAdditionalRawData) + { + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MetricDefinitions() + { + } + + /// the values for the metric definitions. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricNamespace.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricNamespace.Serialization.cs new file mode 100644 index 000000000000..dcdb9e98ba0d --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricNamespace.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.Developer.LoadTesting +{ + public partial class MetricNamespace : 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(MetricNamespace)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MetricNamespace 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(MetricNamespace)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricNamespace(document.RootElement, options); + } + + internal static MetricNamespace DeserializeMetricNamespace(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MetricNamespace(description, name, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MetricNamespace)} does not support writing '{options.Format}' format."); + } + } + + MetricNamespace 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 DeserializeMetricNamespace(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricNamespace)} 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 MetricNamespace FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMetricNamespace(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricNamespace.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricNamespace.cs new file mode 100644 index 000000000000..538d30c5e7bc --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricNamespace.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.Developer.LoadTesting +{ + /// Metric namespace class specifies the metadata for a metric namespace. + public partial class MetricNamespace + { + /// + /// 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 MetricNamespace() + { + } + + /// Initializes a new instance of . + /// The namespace description. + /// The metric namespace name. + /// Keeps track of any properties unknown to the library. + internal MetricNamespace(string description, string name, IDictionary serializedAdditionalRawData) + { + Description = description; + Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The namespace description. + public string Description { get; } + /// The metric namespace name. + public string Name { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricNamespaces.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricNamespaces.Serialization.cs new file mode 100644 index 000000000000..8ddba7ae654e --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricNamespaces.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class MetricNamespaces : 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(MetricNamespaces)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MetricNamespaces 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(MetricNamespaces)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricNamespaces(document.RootElement, options); + } + + internal static MetricNamespaces DeserializeMetricNamespaces(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricNamespace.DeserializeMetricNamespace(item, options)); + } + value = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MetricNamespaces(value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MetricNamespaces)} does not support writing '{options.Format}' format."); + } + } + + MetricNamespaces 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 DeserializeMetricNamespaces(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricNamespaces)} 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 MetricNamespaces FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMetricNamespaces(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricNamespaces.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricNamespaces.cs new file mode 100644 index 000000000000..f9f84c02c45d --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricNamespaces.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.Developer.LoadTesting +{ + /// Represents collection of metric namespaces. + public partial class MetricNamespaces + { + /// + /// 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 values for the metric namespaces. + /// is null. + internal MetricNamespaces(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The values for the metric namespaces. + /// Keeps track of any properties unknown to the library. + internal MetricNamespaces(IReadOnlyList value, IDictionary serializedAdditionalRawData) + { + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MetricNamespaces() + { + } + + /// The values for the metric namespaces. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricUnit.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricUnit.cs new file mode 100644 index 000000000000..d64f0709ccd2 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricUnit.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Metric unit. + public readonly partial struct MetricUnit : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MetricUnit(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NotSpecifiedValue = "NotSpecified"; + private const string PercentValue = "Percent"; + private const string CountValue = "Count"; + private const string SecondsValue = "Seconds"; + private const string MillisecondsValue = "Milliseconds"; + private const string BytesValue = "Bytes"; + private const string BytesPerSecondValue = "BytesPerSecond"; + private const string CountPerSecondValue = "CountPerSecond"; + + /// No unit specified. + public static MetricUnit NotSpecified { get; } = new MetricUnit(NotSpecifiedValue); + /// Percentage. + public static MetricUnit Percent { get; } = new MetricUnit(PercentValue); + /// Value count. + public static MetricUnit Count { get; } = new MetricUnit(CountValue); + /// Seconds. + public static MetricUnit Seconds { get; } = new MetricUnit(SecondsValue); + /// Milliseconds. + public static MetricUnit Milliseconds { get; } = new MetricUnit(MillisecondsValue); + /// Bytes. + public static MetricUnit Bytes { get; } = new MetricUnit(BytesValue); + /// Bytes per second. + public static MetricUnit BytesPerSecond { get; } = new MetricUnit(BytesPerSecondValue); + /// Count per second. + public static MetricUnit CountPerSecond { get; } = new MetricUnit(CountPerSecondValue); + /// Determines if two values are the same. + public static bool operator ==(MetricUnit left, MetricUnit right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MetricUnit left, MetricUnit right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator MetricUnit(string value) => new MetricUnit(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MetricUnit other && Equals(other); + /// + public bool Equals(MetricUnit 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricValue.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricValue.Serialization.cs new file mode 100644 index 000000000000..79c825d7b725 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricValue.Serialization.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class MetricValue : 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(MetricValue)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Timestamp)) + { + writer.WritePropertyName("timestamp"u8); + writer.WriteStringValue(Timestamp.Value, "O"); + } + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteNumberValue(Value.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MetricValue 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(MetricValue)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricValue(document.RootElement, options); + } + + internal static MetricValue DeserializeMetricValue(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset? timestamp = default; + double? value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("timestamp"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + timestamp = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + value = property.Value.GetDouble(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MetricValue(timestamp, value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MetricValue)} does not support writing '{options.Format}' format."); + } + } + + MetricValue 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 DeserializeMetricValue(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricValue)} 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 MetricValue FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMetricValue(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricValue.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricValue.cs new file mode 100644 index 000000000000..e82fbc986e03 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricValue.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.Developer.LoadTesting +{ + /// Represents a metric value. + public partial class MetricValue + { + /// + /// 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 MetricValue() + { + } + + /// Initializes a new instance of . + /// The timestamp for the metric value in RFC 3339 format. + /// The metric value. + /// Keeps track of any properties unknown to the library. + internal MetricValue(DateTimeOffset? timestamp, double? value, IDictionary serializedAdditionalRawData) + { + Timestamp = timestamp; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The timestamp for the metric value in RFC 3339 format. + public DateTimeOffset? Timestamp { get; } + /// The metric value. + public double? Value { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricsFilters.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricsFilters.Serialization.cs new file mode 100644 index 000000000000..f2f0c9253e5c --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricsFilters.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class MetricsFilters : 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(MetricsFilters)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Filters)) + { + writer.WritePropertyName("filters"u8); + writer.WriteStartArray(); + foreach (var item in Filters) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MetricsFilters 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(MetricsFilters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricsFilters(document.RootElement, options); + } + + internal static MetricsFilters DeserializeMetricsFilters(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList filters = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("filters"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DimensionFilter.DeserializeDimensionFilter(item, options)); + } + filters = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MetricsFilters(filters ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MetricsFilters)} does not support writing '{options.Format}' format."); + } + } + + MetricsFilters 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 DeserializeMetricsFilters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricsFilters)} 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 MetricsFilters FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMetricsFilters(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricsFilters.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricsFilters.cs new file mode 100644 index 000000000000..b31007e96aef --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MetricsFilters.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Filters to fetch the set of metric. + public partial class MetricsFilters + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public MetricsFilters() + { + Filters = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// Get metrics for specific dimension values. Example: Metric contains dimension + /// like SamplerName, Error. To retrieve all the time series data where SamplerName + /// is equals to HTTPRequest1 or HTTPRequest2, the DimensionFilter value will be + /// {"SamplerName", ["HTTPRequest1", "HTTPRequest2"} + /// + /// Keeps track of any properties unknown to the library. + internal MetricsFilters(IList filters, IDictionary serializedAdditionalRawData) + { + Filters = filters; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Get metrics for specific dimension values. Example: Metric contains dimension + /// like SamplerName, Error. To retrieve all the time series data where SamplerName + /// is equals to HTTPRequest1 or HTTPRequest2, the DimensionFilter value will be + /// {"SamplerName", ["HTTPRequest1", "HTTPRequest2"} + /// + public IList Filters { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByDates.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByDates.Serialization.cs new file mode 100644 index 000000000000..b2caaaf132a4 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByDates.Serialization.cs @@ -0,0 +1,176 @@ +// 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.Developer.LoadTesting +{ + public partial class MonthlyRecurrenceByDates : 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(MonthlyRecurrenceByDates)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsCollectionDefined(DatesInMonth)) + { + writer.WritePropertyName("datesInMonth"u8); + writer.WriteStartArray(); + foreach (var item in DatesInMonth) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Interval)) + { + writer.WritePropertyName("interval"u8); + writer.WriteNumberValue(Interval.Value); + } + } + + MonthlyRecurrenceByDates 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(MonthlyRecurrenceByDates)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMonthlyRecurrenceByDates(document.RootElement, options); + } + + internal static MonthlyRecurrenceByDates DeserializeMonthlyRecurrenceByDates(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList datesInMonth = default; + int? interval = default; + Frequency frequency = default; + RecurrenceEnd recurrenceEnd = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("datesInMonth"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetInt32()); + } + datesInMonth = array; + continue; + } + if (property.NameEquals("interval"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + interval = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("frequency"u8)) + { + frequency = new Frequency(property.Value.GetString()); + continue; + } + if (property.NameEquals("recurrenceEnd"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MonthlyRecurrenceByDates(frequency, recurrenceEnd, serializedAdditionalRawData, datesInMonth ?? new ChangeTrackingList(), interval); + } + + 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(MonthlyRecurrenceByDates)} does not support writing '{options.Format}' format."); + } + } + + MonthlyRecurrenceByDates 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 DeserializeMonthlyRecurrenceByDates(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MonthlyRecurrenceByDates)} 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 MonthlyRecurrenceByDates FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMonthlyRecurrenceByDates(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByDates.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByDates.cs new file mode 100644 index 000000000000..45bed38c26a3 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByDates.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Recurrence model when frequency is set as MonthlyByDates. + public partial class MonthlyRecurrenceByDates : Recurrence + { + /// Initializes a new instance of . + public MonthlyRecurrenceByDates() + { + Frequency = Frequency.MonthlyByDates; + DatesInMonth = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Frequency of the recurrence. + /// Recurrence end model. You can specify the end either by providing a numberOfOccurrences (which will end the recurrence after the specified number of occurrences) or by providing an endDateTime (which will end the recurrence after the specified date). If neither value is provided, the recurrence will continue until it is manually ended. However, if both values are provided, an error will be thrown. + /// Keeps track of any properties unknown to the library. + /// Recurrence set to repeat on the specified dates of the month. Value of dates can be 1 to 31 and -1. -1 represents the last day of the month. + /// The interval at which the recurrence should repeat. It signifies the number of months between each recurrence. + internal MonthlyRecurrenceByDates(Frequency frequency, RecurrenceEnd recurrenceEnd, IDictionary serializedAdditionalRawData, IList datesInMonth, int? interval) : base(frequency, recurrenceEnd, serializedAdditionalRawData) + { + DatesInMonth = datesInMonth; + Interval = interval; + } + + /// Recurrence set to repeat on the specified dates of the month. Value of dates can be 1 to 31 and -1. -1 represents the last day of the month. + public IList DatesInMonth { get; } + /// The interval at which the recurrence should repeat. It signifies the number of months between each recurrence. + public int? Interval { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByWeekDays.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByWeekDays.Serialization.cs new file mode 100644 index 000000000000..ebace9e0c392 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByWeekDays.Serialization.cs @@ -0,0 +1,183 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class MonthlyRecurrenceByWeekDays : 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(MonthlyRecurrenceByWeekDays)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsCollectionDefined(WeekDaysInMonth)) + { + writer.WritePropertyName("weekDaysInMonth"u8); + writer.WriteStartArray(); + foreach (var item in WeekDaysInMonth) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("interval"u8); + writer.WriteNumberValue(Interval); + } + + MonthlyRecurrenceByWeekDays 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(MonthlyRecurrenceByWeekDays)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMonthlyRecurrenceByWeekDays(document.RootElement, options); + } + + internal static MonthlyRecurrenceByWeekDays DeserializeMonthlyRecurrenceByWeekDays(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList weekDaysInMonth = default; + int index = default; + int interval = default; + Frequency frequency = default; + RecurrenceEnd recurrenceEnd = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("weekDaysInMonth"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new WeekDays(item.GetString())); + } + weekDaysInMonth = array; + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("interval"u8)) + { + interval = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("frequency"u8)) + { + frequency = new Frequency(property.Value.GetString()); + continue; + } + if (property.NameEquals("recurrenceEnd"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MonthlyRecurrenceByWeekDays( + frequency, + recurrenceEnd, + serializedAdditionalRawData, + weekDaysInMonth ?? new ChangeTrackingList(), + index, + interval); + } + + 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(MonthlyRecurrenceByWeekDays)} does not support writing '{options.Format}' format."); + } + } + + MonthlyRecurrenceByWeekDays 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 DeserializeMonthlyRecurrenceByWeekDays(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MonthlyRecurrenceByWeekDays)} 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 MonthlyRecurrenceByWeekDays FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMonthlyRecurrenceByWeekDays(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByWeekDays.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByWeekDays.cs new file mode 100644 index 000000000000..60c744361527 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByWeekDays.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Recurrence model when frequency is set as MonthlyByDays . + public partial class MonthlyRecurrenceByWeekDays : Recurrence + { + /// Initializes a new instance of . + /// Index of the week in a month at which the recurrence should repeat. For example, if the index is '2', weekDay is 'Monday', interval is 3 and frequency is 'Month', the recurrence will run every second Monday of the month and repeat every 3 months. Value of index can be 1 to 5. + /// The interval at which the recurrence should repeat. It signifies the number of months between each recurrence. + public MonthlyRecurrenceByWeekDays(int index, int interval) + { + Frequency = Frequency.MonthlyByDays; + WeekDaysInMonth = new ChangeTrackingList(); + Index = index; + Interval = interval; + } + + /// Initializes a new instance of . + /// Frequency of the recurrence. + /// Recurrence end model. You can specify the end either by providing a numberOfOccurrences (which will end the recurrence after the specified number of occurrences) or by providing an endDateTime (which will end the recurrence after the specified date). If neither value is provided, the recurrence will continue until it is manually ended. However, if both values are provided, an error will be thrown. + /// Keeps track of any properties unknown to the library. + /// Specific days of the week when the recurrence should repeat. + /// Index of the week in a month at which the recurrence should repeat. For example, if the index is '2', weekDay is 'Monday', interval is 3 and frequency is 'Month', the recurrence will run every second Monday of the month and repeat every 3 months. Value of index can be 1 to 5. + /// The interval at which the recurrence should repeat. It signifies the number of months between each recurrence. + internal MonthlyRecurrenceByWeekDays(Frequency frequency, RecurrenceEnd recurrenceEnd, IDictionary serializedAdditionalRawData, IList weekDaysInMonth, int index, int interval) : base(frequency, recurrenceEnd, serializedAdditionalRawData) + { + WeekDaysInMonth = weekDaysInMonth; + Index = index; + Interval = interval; + } + + /// Initializes a new instance of for deserialization. + internal MonthlyRecurrenceByWeekDays() + { + } + + /// Specific days of the week when the recurrence should repeat. + public IList WeekDaysInMonth { get; } + /// Index of the week in a month at which the recurrence should repeat. For example, if the index is '2', weekDay is 'Monday', interval is 3 and frequency is 'Month', the recurrence will run every second Monday of the month and repeat every 3 months. Value of index can be 1 to 5. + public int Index { get; set; } + /// The interval at which the recurrence should repeat. It signifies the number of months between each recurrence. + public int Interval { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/NameAndDescription.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/NameAndDescription.Serialization.cs new file mode 100644 index 000000000000..eed14d39d2f2 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/NameAndDescription.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.Developer.LoadTesting +{ + public partial class NameAndDescription : 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(NameAndDescription)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NameAndDescription 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(NameAndDescription)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNameAndDescription(document.RootElement, options); + } + + internal static NameAndDescription DeserializeNameAndDescription(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NameAndDescription(description, name, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(NameAndDescription)} does not support writing '{options.Format}' format."); + } + } + + NameAndDescription 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 DeserializeNameAndDescription(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NameAndDescription)} 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 NameAndDescription FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNameAndDescription(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/NameAndDescription.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/NameAndDescription.cs new file mode 100644 index 000000000000..3669d22e4369 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/NameAndDescription.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.Developer.LoadTesting +{ + /// The name and description. + public partial class NameAndDescription + { + /// + /// 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 NameAndDescription() + { + } + + /// Initializes a new instance of . + /// The description. + /// The name. + /// Keeps track of any properties unknown to the library. + internal NameAndDescription(string description, string name, IDictionary serializedAdditionalRawData) + { + Description = description; + Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The description. + public string Description { get; } + /// The name. + public string Name { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/NotificationEventType.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/NotificationEventType.cs new file mode 100644 index 000000000000..48b21c47df11 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/NotificationEventType.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Notification event type. + internal readonly partial struct NotificationEventType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public NotificationEventType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string TestRunEndedValue = "TestRunEnded"; + private const string TestRunStartedValue = "TestRunStarted"; + private const string TriggerCompletedValue = "TriggerCompleted"; + private const string TriggerDisabledValue = "TriggerDisabled"; + + /// Test run ended event. This event would occur when a test run reaches terminal state. + public static NotificationEventType TestRunEnded { get; } = new NotificationEventType(TestRunEndedValue); + /// Test run started event. This event would occur when a new test run is triggered. + public static NotificationEventType TestRunStarted { get; } = new NotificationEventType(TestRunStartedValue); + /// Trigger completed event. This event would occur when a trigger completes. + public static NotificationEventType TriggerCompleted { get; } = new NotificationEventType(TriggerCompletedValue); + /// Trigger disabled event. This event would occur when a trigger is disabled. + public static NotificationEventType TriggerDisabled { get; } = new NotificationEventType(TriggerDisabledValue); + /// Determines if two values are the same. + public static bool operator ==(NotificationEventType left, NotificationEventType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(NotificationEventType left, NotificationEventType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator NotificationEventType(string value) => new NotificationEventType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is NotificationEventType other && Equals(other); + /// + public bool Equals(NotificationEventType 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/NotificationRule.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/NotificationRule.Serialization.cs new file mode 100644 index 000000000000..1f5ccc17c967 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/NotificationRule.Serialization.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + [PersistableModelProxy(typeof(UnknownNotificationRule))] + public partial class NotificationRule : 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(NotificationRule)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("notificationRuleId"u8); + writer.WriteStringValue(NotificationRuleId); + } + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + writer.WritePropertyName("actionGroupIds"u8); + writer.WriteStartArray(); + foreach (var item in ActionGroupIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("scope"u8); + writer.WriteStringValue(Scope.ToString()); + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedDateTime)) + { + writer.WritePropertyName("lastModifiedDateTime"u8); + writer.WriteStringValue(LastModifiedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedBy)) + { + writer.WritePropertyName("lastModifiedBy"u8); + writer.WriteStringValue(LastModifiedBy); + } + 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 + } + } + } + + NotificationRule 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(NotificationRule)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNotificationRule(document.RootElement, options); + } + + internal static NotificationRule DeserializeNotificationRule(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("scope", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "Tests": return TestsNotificationRule.DeserializeTestsNotificationRule(element, options); + } + } + return UnknownNotificationRule.DeserializeUnknownNotificationRule(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(NotificationRule)} does not support writing '{options.Format}' format."); + } + } + + NotificationRule 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 DeserializeNotificationRule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NotificationRule)} 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 NotificationRule FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNotificationRule(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/NotificationRule.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/NotificationRule.cs new file mode 100644 index 000000000000..ceb4f13074b9 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/NotificationRule.cs @@ -0,0 +1,111 @@ +// 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.Developer.LoadTesting +{ + /// + /// Notification rule model. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + public abstract partial class NotificationRule + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The name of the notification rule. + /// The action groups to notify. + /// or is null. + protected NotificationRule(string displayName, IEnumerable actionGroupIds) + { + Argument.AssertNotNull(displayName, nameof(displayName)); + Argument.AssertNotNull(actionGroupIds, nameof(actionGroupIds)); + + DisplayName = displayName; + ActionGroupIds = actionGroupIds.ToList(); + } + + /// Initializes a new instance of . + /// The unique identifier of the notification rule. + /// The name of the notification rule. + /// The action groups to notify. + /// The scope of the notification rule. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal NotificationRule(string notificationRuleId, string displayName, IList actionGroupIds, NotificationScopeType scope, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + { + NotificationRuleId = notificationRuleId; + DisplayName = displayName; + ActionGroupIds = actionGroupIds; + Scope = scope; + CreatedDateTime = createdDateTime; + CreatedBy = createdBy; + LastModifiedDateTime = lastModifiedDateTime; + LastModifiedBy = lastModifiedBy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal NotificationRule() + { + } + + /// The unique identifier of the notification rule. + public string NotificationRuleId { get; } + /// The name of the notification rule. + public string DisplayName { get; set; } + /// The action groups to notify. + public IList ActionGroupIds { get; } + /// The scope of the notification rule. + internal NotificationScopeType Scope { get; set; } + /// The creation datetime(RFC 3339 literal format). + public DateTimeOffset? CreatedDateTime { get; } + /// The user that created. + public string CreatedBy { get; } + /// The last Modified datetime(RFC 3339 literal format). + public DateTimeOffset? LastModifiedDateTime { get; } + /// The user that last modified. + public string LastModifiedBy { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/NotificationScopeType.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/NotificationScopeType.cs new file mode 100644 index 000000000000..c0d611e90f35 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/NotificationScopeType.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Scope type of a notification rule. + internal readonly partial struct NotificationScopeType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public NotificationScopeType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string TestsValue = "Tests"; + + /// Notification rule is for Tests. + public static NotificationScopeType Tests { get; } = new NotificationScopeType(TestsValue); + /// Determines if two values are the same. + public static bool operator ==(NotificationScopeType left, NotificationScopeType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(NotificationScopeType left, NotificationScopeType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator NotificationScopeType(string value) => new NotificationScopeType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is NotificationScopeType other && Equals(other); + /// + public bool Equals(NotificationScopeType 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/OperationKind.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/OperationKind.cs new file mode 100644 index 000000000000..ea9d2a4935d6 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/OperationKind.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Kind of the long running operation. + public readonly partial struct OperationKind : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OperationKind(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string CloneTestValue = "CloneTest"; + + /// Operation represents a clone test operation. + public static OperationKind CloneTest { get; } = new OperationKind(CloneTestValue); + /// Determines if two values are the same. + public static bool operator ==(OperationKind left, OperationKind right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OperationKind left, OperationKind right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator OperationKind(string value) => new OperationKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OperationKind other && Equals(other); + /// + public bool Equals(OperationKind 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/OperationState.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/OperationState.cs new file mode 100644 index 000000000000..4ecb60454dcd --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/OperationState.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Enum describing allowed operation states. + public readonly partial struct OperationState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OperationState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NotStartedValue = "NotStarted"; + private const string RunningValue = "Running"; + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string CanceledValue = "Canceled"; + + /// The operation has not started. + public static OperationState NotStarted { get; } = new OperationState(NotStartedValue); + /// The operation is in progress. + public static OperationState Running { get; } = new OperationState(RunningValue); + /// The operation has completed successfully. + public static OperationState Succeeded { get; } = new OperationState(SucceededValue); + /// The operation has failed. + public static OperationState Failed { get; } = new OperationState(FailedValue); + /// The operation has been canceled by the user. + public static OperationState Canceled { get; } = new OperationState(CanceledValue); + /// Determines if two values are the same. + public static bool operator ==(OperationState left, OperationState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OperationState left, OperationState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator OperationState(string value) => new OperationState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OperationState other && Equals(other); + /// + public bool Equals(OperationState 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/OperationStatus.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/OperationStatus.Serialization.cs new file mode 100644 index 000000000000..1c2eaf2725d6 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/OperationStatus.Serialization.cs @@ -0,0 +1,176 @@ +// 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.Developer.LoadTesting +{ + public partial class OperationStatus : 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(OperationStatus)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.ToString()); + if (Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + JsonSerializer.Serialize(writer, Error); + } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + 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 + } + } + } + + OperationStatus 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(OperationStatus)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOperationStatus(document.RootElement, options); + } + + internal static OperationStatus DeserializeOperationStatus(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OperationState status = default; + OperationKind kind = default; + ResponseError error = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("status"u8)) + { + status = new OperationState(property.Value.GetString()); + continue; + } + if (property.NameEquals("kind"u8)) + { + kind = new OperationKind(property.Value.GetString()); + continue; + } + if (property.NameEquals("error"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + error = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OperationStatus(status, kind, error, id, 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(OperationStatus)} does not support writing '{options.Format}' format."); + } + } + + OperationStatus 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 DeserializeOperationStatus(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OperationStatus)} 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 OperationStatus FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOperationStatus(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/OperationStatus.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/OperationStatus.cs new file mode 100644 index 000000000000..ca2a2b528b9a --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/OperationStatus.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.Developer.LoadTesting +{ + /// Status of a long running operation. + public partial class OperationStatus + { + /// + /// 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 state of the operation. + /// The kind of the operation. + internal OperationStatus(OperationState status, OperationKind kind) + { + Status = status; + Kind = kind; + } + + /// Initializes a new instance of . + /// The state of the operation. + /// The kind of the operation. + /// Error object that describes the error when status is "Failed". + /// The unique ID of the operation. + /// Keeps track of any properties unknown to the library. + internal OperationStatus(OperationState status, OperationKind kind, ResponseError error, string id, IDictionary serializedAdditionalRawData) + { + Status = status; + Kind = kind; + Error = error; + Id = id; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OperationStatus() + { + } + + /// The state of the operation. + public OperationState Status { get; } + /// The kind of the operation. + public OperationKind Kind { get; } + /// Error object that describes the error when status is "Failed". + public ResponseError Error { get; } + /// The unique ID of the operation. + public string Id { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/OptionalLoadTestConfiguration.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/OptionalLoadTestConfiguration.Serialization.cs new file mode 100644 index 000000000000..f737023a0216 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/OptionalLoadTestConfiguration.Serialization.cs @@ -0,0 +1,231 @@ +// 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.Developer.LoadTesting +{ + public partial class OptionalLoadTestConfiguration : 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(OptionalLoadTestConfiguration)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(EndpointUri)) + { + writer.WritePropertyName("endpointUrl"u8); + writer.WriteStringValue(EndpointUri.AbsoluteUri); + } + if (Optional.IsDefined(RequestsPerSecond)) + { + writer.WritePropertyName("requestsPerSecond"u8); + writer.WriteNumberValue(RequestsPerSecond.Value); + } + if (Optional.IsDefined(MaxResponseTimeInMs)) + { + writer.WritePropertyName("maxResponseTimeInMs"u8); + writer.WriteNumberValue(MaxResponseTimeInMs.Value); + } + if (Optional.IsDefined(VirtualUsers)) + { + writer.WritePropertyName("virtualUsers"u8); + writer.WriteNumberValue(VirtualUsers.Value); + } + if (Optional.IsDefined(RampUpTime)) + { + writer.WritePropertyName("rampUpTime"u8); + writer.WriteNumberValue(RampUpTime.Value); + } + if (Optional.IsDefined(Duration)) + { + writer.WritePropertyName("duration"u8); + writer.WriteNumberValue(Convert.ToInt32(Duration.Value.ToString("%s"))); + } + 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 + } + } + } + + OptionalLoadTestConfiguration 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(OptionalLoadTestConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOptionalLoadTestConfiguration(document.RootElement, options); + } + + internal static OptionalLoadTestConfiguration DeserializeOptionalLoadTestConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Uri endpointUrl = default; + int? requestsPerSecond = default; + int? maxResponseTimeInMs = default; + int? virtualUsers = default; + int? rampUpTime = default; + TimeSpan? duration = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("endpointUrl"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endpointUrl = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("requestsPerSecond"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + requestsPerSecond = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("maxResponseTimeInMs"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxResponseTimeInMs = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("virtualUsers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + virtualUsers = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("rampUpTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + rampUpTime = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("duration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + duration = TimeSpan.FromSeconds(property.Value.GetInt32()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OptionalLoadTestConfiguration( + endpointUrl, + requestsPerSecond, + maxResponseTimeInMs, + virtualUsers, + rampUpTime, + duration, + 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(OptionalLoadTestConfiguration)} does not support writing '{options.Format}' format."); + } + } + + OptionalLoadTestConfiguration 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 DeserializeOptionalLoadTestConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OptionalLoadTestConfiguration)} 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 OptionalLoadTestConfiguration FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOptionalLoadTestConfiguration(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/OptionalLoadTestConfiguration.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/OptionalLoadTestConfiguration.cs new file mode 100644 index 000000000000..1fe5782307a2 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/OptionalLoadTestConfiguration.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Configuration for quick load test. + public partial class OptionalLoadTestConfiguration + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public OptionalLoadTestConfiguration() + { + } + + /// Initializes a new instance of . + /// Test URL. Provide the complete HTTP URL. For example, https://contoso-app.azurewebsites.net/login. + /// Target throughput (requests per second). This may not be necessarily achieved. The actual throughput will be lower if the application is not capable of handling it. + /// Maximum response time in milliseconds of the API/endpoint. + /// No of concurrent virtual users. + /// Ramp up time in seconds. + /// Test run duration in seconds. + /// Keeps track of any properties unknown to the library. + internal OptionalLoadTestConfiguration(Uri endpointUri, int? requestsPerSecond, int? maxResponseTimeInMs, int? virtualUsers, int? rampUpTime, TimeSpan? duration, IDictionary serializedAdditionalRawData) + { + EndpointUri = endpointUri; + RequestsPerSecond = requestsPerSecond; + MaxResponseTimeInMs = maxResponseTimeInMs; + VirtualUsers = virtualUsers; + RampUpTime = rampUpTime; + Duration = duration; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Test URL. Provide the complete HTTP URL. For example, https://contoso-app.azurewebsites.net/login. + public Uri EndpointUri { get; set; } + /// Target throughput (requests per second). This may not be necessarily achieved. The actual throughput will be lower if the application is not capable of handling it. + public int? RequestsPerSecond { get; set; } + /// Maximum response time in milliseconds of the API/endpoint. + public int? MaxResponseTimeInMs { get; set; } + /// No of concurrent virtual users. + public int? VirtualUsers { get; set; } + /// Ramp up time in seconds. + public int? RampUpTime { get; set; } + /// Test run duration in seconds. + public TimeSpan? Duration { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailAction.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailAction.cs new file mode 100644 index 000000000000..15672f674687 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailAction.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Action to take on failure of pass/fail criteria. + public readonly partial struct PassFailAction : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PassFailAction(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ContinueValue = "continue"; + private const string StopValue = "stop"; + + /// Test will continue to run even if pass fail metric criteria metric gets failed. + public static PassFailAction Continue { get; } = new PassFailAction(ContinueValue); + /// Test run will stop if pass fail criteria metric is not passed. + public static PassFailAction Stop { get; } = new PassFailAction(StopValue); + /// Determines if two values are the same. + public static bool operator ==(PassFailAction left, PassFailAction right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PassFailAction left, PassFailAction right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PassFailAction(string value) => new PassFailAction(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PassFailAction other && Equals(other); + /// + public bool Equals(PassFailAction 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailAggregationFunction.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailAggregationFunction.cs new file mode 100644 index 000000000000..bec34915adcb --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailAggregationFunction.cs @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Aggregation functions for pass/fail criteria. + public readonly partial struct PassFailAggregationFunction : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PassFailAggregationFunction(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string CountValue = "count"; + private const string PercentageValue = "percentage"; + private const string AverageValue = "avg"; + private const string Percentile50Value = "p50"; + private const string Percentile75Value = "p75"; + private const string Percentile90Value = "p90"; + private const string Percentile95Value = "p95"; + private const string Percentile96Value = "p96"; + private const string Percentile97Value = "p97"; + private const string Percentile98Value = "p98"; + private const string Percentile99Value = "p99"; + private const string Percentile999Value = "p99.9"; + private const string Percentile9999Value = "p99.99"; + private const string MinimumValue = "min"; + private const string MaximumValue = "max"; + + /// Criteria applies for count value. + public static PassFailAggregationFunction Count { get; } = new PassFailAggregationFunction(CountValue); + /// Criteria applies for given percentage value. + public static PassFailAggregationFunction Percentage { get; } = new PassFailAggregationFunction(PercentageValue); + /// Criteria applies for avg value. + public static PassFailAggregationFunction Average { get; } = new PassFailAggregationFunction(AverageValue); + /// Criteria applies for 50th percentile value. + public static PassFailAggregationFunction Percentile50 { get; } = new PassFailAggregationFunction(Percentile50Value); + /// Criteria applies for 75th percentile value. + public static PassFailAggregationFunction Percentile75 { get; } = new PassFailAggregationFunction(Percentile75Value); + /// Criteria applies for 90th percentile value. + public static PassFailAggregationFunction Percentile90 { get; } = new PassFailAggregationFunction(Percentile90Value); + /// Criteria applies for 95th percentile value. + public static PassFailAggregationFunction Percentile95 { get; } = new PassFailAggregationFunction(Percentile95Value); + /// Criteria applies for 96th percentile value. + public static PassFailAggregationFunction Percentile96 { get; } = new PassFailAggregationFunction(Percentile96Value); + /// Criteria applies for 97th percentile value. + public static PassFailAggregationFunction Percentile97 { get; } = new PassFailAggregationFunction(Percentile97Value); + /// Criteria applies for 98th percentile value. + public static PassFailAggregationFunction Percentile98 { get; } = new PassFailAggregationFunction(Percentile98Value); + /// Criteria applies for 99th percentile value. + public static PassFailAggregationFunction Percentile99 { get; } = new PassFailAggregationFunction(Percentile99Value); + /// Criteria applies for 99.9th percentile value. + public static PassFailAggregationFunction Percentile999 { get; } = new PassFailAggregationFunction(Percentile999Value); + /// Criteria applies for 99.99th percentile value. + public static PassFailAggregationFunction Percentile9999 { get; } = new PassFailAggregationFunction(Percentile9999Value); + /// Criteria applies for minimum value. + public static PassFailAggregationFunction Minimum { get; } = new PassFailAggregationFunction(MinimumValue); + /// Criteria applies for maximum value. + public static PassFailAggregationFunction Maximum { get; } = new PassFailAggregationFunction(MaximumValue); + /// Determines if two values are the same. + public static bool operator ==(PassFailAggregationFunction left, PassFailAggregationFunction right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PassFailAggregationFunction left, PassFailAggregationFunction right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PassFailAggregationFunction(string value) => new PassFailAggregationFunction(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PassFailAggregationFunction other && Equals(other); + /// + public bool Equals(PassFailAggregationFunction 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailCriteria.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailCriteria.Serialization.cs new file mode 100644 index 000000000000..60e90b9d81a9 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailCriteria.Serialization.cs @@ -0,0 +1,186 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class PassFailCriteria : 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(PassFailCriteria)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(PassFailMetrics)) + { + writer.WritePropertyName("passFailMetrics"u8); + writer.WriteStartObject(); + foreach (var item in PassFailMetrics) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (Optional.IsCollectionDefined(PassFailServerMetrics)) + { + writer.WritePropertyName("passFailServerMetrics"u8); + writer.WriteStartObject(); + foreach (var item in PassFailServerMetrics) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PassFailCriteria 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(PassFailCriteria)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePassFailCriteria(document.RootElement, options); + } + + internal static PassFailCriteria DeserializePassFailCriteria(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary passFailMetrics = default; + IDictionary passFailServerMetrics = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("passFailMetrics"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, PassFailMetric.DeserializePassFailMetric(property0.Value, options)); + } + passFailMetrics = dictionary; + continue; + } + if (property.NameEquals("passFailServerMetrics"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, PassFailServerMetric.DeserializePassFailServerMetric(property0.Value, options)); + } + passFailServerMetrics = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PassFailCriteria(passFailMetrics ?? new ChangeTrackingDictionary(), passFailServerMetrics ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(PassFailCriteria)} does not support writing '{options.Format}' format."); + } + } + + PassFailCriteria 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 DeserializePassFailCriteria(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PassFailCriteria)} 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 PassFailCriteria FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePassFailCriteria(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailCriteria.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailCriteria.cs new file mode 100644 index 000000000000..f2dc32a480e5 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailCriteria.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Pass fail criteria for a test. + public partial class PassFailCriteria + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public PassFailCriteria() + { + PassFailMetrics = new ChangeTrackingDictionary(); + PassFailServerMetrics = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Map of id and pass fail metrics { id : pass fail metrics }. + /// Map of id and pass fail server metrics { id : pass fail metrics }. + /// Keeps track of any properties unknown to the library. + internal PassFailCriteria(IDictionary passFailMetrics, IDictionary passFailServerMetrics, IDictionary serializedAdditionalRawData) + { + PassFailMetrics = passFailMetrics; + PassFailServerMetrics = passFailServerMetrics; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Map of id and pass fail metrics { id : pass fail metrics }. + public IDictionary PassFailMetrics { get; } + /// Map of id and pass fail server metrics { id : pass fail metrics }. + public IDictionary PassFailServerMetrics { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailMetric.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailMetric.Serialization.cs new file mode 100644 index 000000000000..9daf80f84e05 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailMetric.Serialization.cs @@ -0,0 +1,255 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class PassFailMetric : 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(PassFailMetric)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ClientMetric)) + { + writer.WritePropertyName("clientMetric"u8); + writer.WriteStringValue(ClientMetric.Value.ToString()); + } + if (Optional.IsDefined(Aggregate)) + { + writer.WritePropertyName("aggregate"u8); + writer.WriteStringValue(Aggregate.Value.ToString()); + } + if (Optional.IsDefined(Condition)) + { + writer.WritePropertyName("condition"u8); + writer.WriteStringValue(Condition); + } + if (Optional.IsDefined(RequestName)) + { + writer.WritePropertyName("requestName"u8); + writer.WriteStringValue(RequestName); + } + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteNumberValue(Value.Value); + } + if (Optional.IsDefined(Action)) + { + writer.WritePropertyName("action"u8); + writer.WriteStringValue(Action.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ActualValue)) + { + writer.WritePropertyName("actualValue"u8); + writer.WriteNumberValue(ActualValue.Value); + } + if (options.Format != "W" && Optional.IsDefined(Result)) + { + writer.WritePropertyName("result"u8); + writer.WriteStringValue(Result.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PassFailMetric 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(PassFailMetric)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePassFailMetric(document.RootElement, options); + } + + internal static PassFailMetric DeserializePassFailMetric(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + PfMetrics? clientMetric = default; + PassFailAggregationFunction? aggregate = default; + string condition = default; + string requestName = default; + double? value = default; + PassFailAction? action = default; + double? actualValue = default; + PassFailResult? result = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("clientMetric"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + clientMetric = new PfMetrics(property.Value.GetString()); + continue; + } + if (property.NameEquals("aggregate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + aggregate = new PassFailAggregationFunction(property.Value.GetString()); + continue; + } + if (property.NameEquals("condition"u8)) + { + condition = property.Value.GetString(); + continue; + } + if (property.NameEquals("requestName"u8)) + { + requestName = property.Value.GetString(); + continue; + } + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + value = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("action"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + action = new PassFailAction(property.Value.GetString()); + continue; + } + if (property.NameEquals("actualValue"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + actualValue = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("result"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + result = new PassFailResult(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PassFailMetric( + clientMetric, + aggregate, + condition, + requestName, + value, + action, + actualValue, + 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(PassFailMetric)} does not support writing '{options.Format}' format."); + } + } + + PassFailMetric 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 DeserializePassFailMetric(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PassFailMetric)} 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 PassFailMetric FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePassFailMetric(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailMetric.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailMetric.cs new file mode 100644 index 000000000000..623cd825a9d1 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailMetric.cs @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Pass fail metric. + public partial class PassFailMetric + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public PassFailMetric() + { + } + + /// Initializes a new instance of . + /// The client metric on which the criteria should be applied. + /// + /// The aggregation function to be applied on the client metric. Allowed functions + /// - ‘percentage’ - for error metric , ‘avg’, percentiles like ‘p50’, ‘p90’, & so on, ‘min’, + /// ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, + /// ‘count’ - for requests + /// + /// The comparison operator. Supported types ‘>’, ‘<’. + /// Request name for which the Pass fail criteria has to be applied. + /// + /// The value to compare with the client metric. Allowed values - ‘error : [0.0 , + /// 100.0] unit- % ’, response_time_ms and latency : any integer value unit- ms. + /// + /// Action taken after the threshold is met. Default is ‘continue’. + /// The actual value of the client metric for the test run. + /// Outcome of the test run. + /// Keeps track of any properties unknown to the library. + internal PassFailMetric(PfMetrics? clientMetric, PassFailAggregationFunction? aggregate, string condition, string requestName, double? value, PassFailAction? action, double? actualValue, PassFailResult? result, IDictionary serializedAdditionalRawData) + { + ClientMetric = clientMetric; + Aggregate = aggregate; + Condition = condition; + RequestName = requestName; + Value = value; + Action = action; + ActualValue = actualValue; + Result = result; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The client metric on which the criteria should be applied. + public PfMetrics? ClientMetric { get; set; } + /// + /// The aggregation function to be applied on the client metric. Allowed functions + /// - ‘percentage’ - for error metric , ‘avg’, percentiles like ‘p50’, ‘p90’, & so on, ‘min’, + /// ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, + /// ‘count’ - for requests + /// + public PassFailAggregationFunction? Aggregate { get; set; } + /// The comparison operator. Supported types ‘>’, ‘<’. + public string Condition { get; set; } + /// Request name for which the Pass fail criteria has to be applied. + public string RequestName { get; set; } + /// + /// The value to compare with the client metric. Allowed values - ‘error : [0.0 , + /// 100.0] unit- % ’, response_time_ms and latency : any integer value unit- ms. + /// + public double? Value { get; set; } + /// Action taken after the threshold is met. Default is ‘continue’. + public PassFailAction? Action { get; set; } + /// The actual value of the client metric for the test run. + public double? ActualValue { get; } + /// Outcome of the test run. + public PassFailResult? Result { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailResult.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailResult.cs new file mode 100644 index 000000000000..322a04ecded0 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailResult.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.Developer.LoadTesting +{ + /// Pass/fail criteria result. + public readonly partial struct PassFailResult : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PassFailResult(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PassedValue = "passed"; + private const string UndeterminedValue = "undetermined"; + private const string FailedValue = "failed"; + + /// Given pass fail criteria metric has passed. + public static PassFailResult Passed { get; } = new PassFailResult(PassedValue); + /// Given pass fail criteria metric couldn't determine. + public static PassFailResult Undetermined { get; } = new PassFailResult(UndeterminedValue); + /// Given pass fail criteria metric has failed. + public static PassFailResult Failed { get; } = new PassFailResult(FailedValue); + /// Determines if two values are the same. + public static bool operator ==(PassFailResult left, PassFailResult right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PassFailResult left, PassFailResult right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PassFailResult(string value) => new PassFailResult(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PassFailResult other && Equals(other); + /// + public bool Equals(PassFailResult 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailServerMetric.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailServerMetric.Serialization.cs new file mode 100644 index 000000000000..7345fc91d6f4 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailServerMetric.Serialization.cs @@ -0,0 +1,237 @@ +// 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.Developer.LoadTesting +{ + public partial class PassFailServerMetric : 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(PassFailServerMetric)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("resourceId"u8); + writer.WriteStringValue(ResourceId); + writer.WritePropertyName("metricNamespace"u8); + writer.WriteStringValue(MetricNamespace); + writer.WritePropertyName("metricName"u8); + writer.WriteStringValue(MetricName); + writer.WritePropertyName("aggregation"u8); + writer.WriteStringValue(Aggregation); + writer.WritePropertyName("condition"u8); + writer.WriteStringValue(Condition); + writer.WritePropertyName("value"u8); + writer.WriteNumberValue(Value); + if (Optional.IsDefined(Action)) + { + writer.WritePropertyName("action"u8); + writer.WriteStringValue(Action.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ActualValue)) + { + writer.WritePropertyName("actualValue"u8); + writer.WriteNumberValue(ActualValue.Value); + } + if (options.Format != "W" && Optional.IsDefined(Result)) + { + writer.WritePropertyName("result"u8); + writer.WriteStringValue(Result.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PassFailServerMetric 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(PassFailServerMetric)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePassFailServerMetric(document.RootElement, options); + } + + internal static PassFailServerMetric DeserializePassFailServerMetric(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier resourceId = default; + string metricNamespace = default; + string metricName = default; + string aggregation = default; + string condition = default; + double value = default; + PassFailAction? action = default; + double? actualValue = default; + PassFailResult? result = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceId"u8)) + { + resourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("metricNamespace"u8)) + { + metricNamespace = property.Value.GetString(); + continue; + } + if (property.NameEquals("metricName"u8)) + { + metricName = property.Value.GetString(); + continue; + } + if (property.NameEquals("aggregation"u8)) + { + aggregation = property.Value.GetString(); + continue; + } + if (property.NameEquals("condition"u8)) + { + condition = property.Value.GetString(); + continue; + } + if (property.NameEquals("value"u8)) + { + value = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("action"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + action = new PassFailAction(property.Value.GetString()); + continue; + } + if (property.NameEquals("actualValue"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + actualValue = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("result"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + result = new PassFailResult(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PassFailServerMetric( + resourceId, + metricNamespace, + metricName, + aggregation, + condition, + value, + action, + actualValue, + 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(PassFailServerMetric)} does not support writing '{options.Format}' format."); + } + } + + PassFailServerMetric 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 DeserializePassFailServerMetric(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PassFailServerMetric)} 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 PassFailServerMetric FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePassFailServerMetric(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailServerMetric.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailServerMetric.cs new file mode 100644 index 000000000000..e595efde037e --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailServerMetric.cs @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + /// Pass fail server metric. + public partial class PassFailServerMetric + { + /// + /// 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 resource id of the resource emitting the metric. + /// The server metric namespace. + /// The server metric name. + /// Aggregation Type. + /// The comparison operator. Supported types ‘>’, ‘<’. + /// The value to compare with the server metric. + /// , , , or is null. + public PassFailServerMetric(ResourceIdentifier resourceId, string metricNamespace, string metricName, string aggregation, string condition, double value) + { + Argument.AssertNotNull(resourceId, nameof(resourceId)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(metricName, nameof(metricName)); + Argument.AssertNotNull(aggregation, nameof(aggregation)); + Argument.AssertNotNull(condition, nameof(condition)); + + ResourceId = resourceId; + MetricNamespace = metricNamespace; + MetricName = metricName; + Aggregation = aggregation; + Condition = condition; + Value = value; + } + + /// Initializes a new instance of . + /// The resource id of the resource emitting the metric. + /// The server metric namespace. + /// The server metric name. + /// Aggregation Type. + /// The comparison operator. Supported types ‘>’, ‘<’. + /// The value to compare with the server metric. + /// Action taken after the threshold is met. Default is ‘continue’. + /// The actual value of the server metric. + /// Outcome of the test run. + /// Keeps track of any properties unknown to the library. + internal PassFailServerMetric(ResourceIdentifier resourceId, string metricNamespace, string metricName, string aggregation, string condition, double value, PassFailAction? action, double? actualValue, PassFailResult? result, IDictionary serializedAdditionalRawData) + { + ResourceId = resourceId; + MetricNamespace = metricNamespace; + MetricName = metricName; + Aggregation = aggregation; + Condition = condition; + Value = value; + Action = action; + ActualValue = actualValue; + Result = result; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal PassFailServerMetric() + { + } + + /// The resource id of the resource emitting the metric. + public ResourceIdentifier ResourceId { get; set; } + /// The server metric namespace. + public string MetricNamespace { get; set; } + /// The server metric name. + public string MetricName { get; set; } + /// Aggregation Type. + public string Aggregation { get; set; } + /// The comparison operator. Supported types ‘>’, ‘<’. + public string Condition { get; set; } + /// The value to compare with the server metric. + public double Value { get; set; } + /// Action taken after the threshold is met. Default is ‘continue’. + public PassFailAction? Action { get; set; } + /// The actual value of the server metric. + public double? ActualValue { get; } + /// Outcome of the test run. + public PassFailResult? Result { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailTestResult.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailTestResult.cs new file mode 100644 index 000000000000..9e9ba8dcff58 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PassFailTestResult.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.Developer.LoadTesting +{ + /// Test result based on pass/fail criteria. + public readonly partial struct PassFailTestResult : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PassFailTestResult(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PASSEDValue = "PASSED"; + private const string NOTAPPLICABLEValue = "NOT_APPLICABLE"; + private const string FAILEDValue = "FAILED"; + + /// Pass/fail criteria has passed. + public static PassFailTestResult PASSED { get; } = new PassFailTestResult(PASSEDValue); + /// Pass/fail criteria is not applicable. + public static PassFailTestResult NOTAPPLICABLE { get; } = new PassFailTestResult(NOTAPPLICABLEValue); + /// Pass/fail criteria has failed. + public static PassFailTestResult FAILED { get; } = new PassFailTestResult(FAILEDValue); + /// Determines if two values are the same. + public static bool operator ==(PassFailTestResult left, PassFailTestResult right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PassFailTestResult left, PassFailTestResult right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PassFailTestResult(string value) => new PassFailTestResult(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PassFailTestResult other && Equals(other); + /// + public bool Equals(PassFailTestResult 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/PfMetrics.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PfMetrics.cs new file mode 100644 index 000000000000..cd959571727a --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/PfMetrics.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Metrics for pass/fail criteria. + public readonly partial struct PfMetrics : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PfMetrics(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ResponseTimeInMillisecondsValue = "response_time_ms"; + private const string LatencyValue = "latency"; + private const string ErrorValue = "error"; + private const string RequestsValue = "requests"; + private const string RequestsPerSecondValue = "requests_per_sec"; + + /// Pass fail criteria for response time metric in milliseconds. + public static PfMetrics ResponseTimeInMilliseconds { get; } = new PfMetrics(ResponseTimeInMillisecondsValue); + /// Pass fail criteria for latency metric in milliseconds. + public static PfMetrics Latency { get; } = new PfMetrics(LatencyValue); + /// Pass fail criteria for error metric. + public static PfMetrics Error { get; } = new PfMetrics(ErrorValue); + /// Pass fail criteria for total requests. + public static PfMetrics Requests { get; } = new PfMetrics(RequestsValue); + /// Pass fail criteria for request per second. + public static PfMetrics RequestsPerSecond { get; } = new PfMetrics(RequestsPerSecondValue); + /// Determines if two values are the same. + public static bool operator ==(PfMetrics left, PfMetrics right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PfMetrics left, PfMetrics right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PfMetrics(string value) => new PfMetrics(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PfMetrics other && Equals(other); + /// + public bool Equals(PfMetrics 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecommendationCategory.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecommendationCategory.cs new file mode 100644 index 000000000000..588b050d7070 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecommendationCategory.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Category of Recommendation. + public readonly partial struct RecommendationCategory : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RecommendationCategory(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThroughputOptimizedValue = "ThroughputOptimized"; + private const string CostOptimizedValue = "CostOptimized"; + + /// The recommendation for this category optimizes the throughput/RPS (Requests per Second) of the app. + public static RecommendationCategory ThroughputOptimized { get; } = new RecommendationCategory(ThroughputOptimizedValue); + /// The recommendation for this category optimizes the cost of the app. + public static RecommendationCategory CostOptimized { get; } = new RecommendationCategory(CostOptimizedValue); + /// Determines if two values are the same. + public static bool operator ==(RecommendationCategory left, RecommendationCategory right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RecommendationCategory left, RecommendationCategory right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator RecommendationCategory(string value) => new RecommendationCategory(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RecommendationCategory other && Equals(other); + /// + public bool Equals(RecommendationCategory 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/Recurrence.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Recurrence.Serialization.cs new file mode 100644 index 000000000000..6972e12dec7d --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Recurrence.Serialization.cs @@ -0,0 +1,143 @@ +// 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.Developer.LoadTesting +{ + [PersistableModelProxy(typeof(UnknownRecurrence))] + public partial class Recurrence : 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(Recurrence)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("frequency"u8); + writer.WriteStringValue(Frequency.ToString()); + if (Optional.IsDefined(RecurrenceEnd)) + { + writer.WritePropertyName("recurrenceEnd"u8); + writer.WriteObjectValue(RecurrenceEnd, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Recurrence 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(Recurrence)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRecurrence(document.RootElement, options); + } + + internal static Recurrence DeserializeRecurrence(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("frequency", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "Cron": return RecurrenceWithCron.DeserializeRecurrenceWithCron(element, options); + case "Daily": return DailyRecurrence.DeserializeDailyRecurrence(element, options); + case "Hourly": return HourlyRecurrence.DeserializeHourlyRecurrence(element, options); + case "MonthlyByDates": return MonthlyRecurrenceByDates.DeserializeMonthlyRecurrenceByDates(element, options); + case "MonthlyByDays": return MonthlyRecurrenceByWeekDays.DeserializeMonthlyRecurrenceByWeekDays(element, options); + case "Weekly": return WeeklyRecurrence.DeserializeWeeklyRecurrence(element, options); + } + } + return UnknownRecurrence.DeserializeUnknownRecurrence(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(Recurrence)} does not support writing '{options.Format}' format."); + } + } + + Recurrence 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 DeserializeRecurrence(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Recurrence)} 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 Recurrence FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRecurrence(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/Recurrence.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Recurrence.cs new file mode 100644 index 000000000000..0a074c0a159e --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Recurrence.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// + /// Recurrence model. + /// 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 Recurrence + { + /// + /// 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 Recurrence() + { + } + + /// Initializes a new instance of . + /// Frequency of the recurrence. + /// Recurrence end model. You can specify the end either by providing a numberOfOccurrences (which will end the recurrence after the specified number of occurrences) or by providing an endDateTime (which will end the recurrence after the specified date). If neither value is provided, the recurrence will continue until it is manually ended. However, if both values are provided, an error will be thrown. + /// Keeps track of any properties unknown to the library. + internal Recurrence(Frequency frequency, RecurrenceEnd recurrenceEnd, IDictionary serializedAdditionalRawData) + { + Frequency = frequency; + RecurrenceEnd = recurrenceEnd; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Frequency of the recurrence. + internal Frequency Frequency { get; set; } + /// Recurrence end model. You can specify the end either by providing a numberOfOccurrences (which will end the recurrence after the specified number of occurrences) or by providing an endDateTime (which will end the recurrence after the specified date). If neither value is provided, the recurrence will continue until it is manually ended. However, if both values are provided, an error will be thrown. + public RecurrenceEnd RecurrenceEnd { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecurrenceEnd.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecurrenceEnd.Serialization.cs new file mode 100644 index 000000000000..d5ed9a875521 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecurrenceEnd.Serialization.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class RecurrenceEnd : 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(RecurrenceEnd)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(NumberOfOccurrences)) + { + writer.WritePropertyName("numberOfOccurrences"u8); + writer.WriteNumberValue(NumberOfOccurrences.Value); + } + if (Optional.IsDefined(EndDateTime)) + { + writer.WritePropertyName("endDateTime"u8); + writer.WriteStringValue(EndDateTime.Value, "O"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RecurrenceEnd 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(RecurrenceEnd)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRecurrenceEnd(document.RootElement, options); + } + + internal static RecurrenceEnd DeserializeRecurrenceEnd(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? numberOfOccurrences = default; + DateTimeOffset? endDateTime = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("numberOfOccurrences"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + numberOfOccurrences = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("endDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RecurrenceEnd(numberOfOccurrences, endDateTime, 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(RecurrenceEnd)} does not support writing '{options.Format}' format."); + } + } + + RecurrenceEnd 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 DeserializeRecurrenceEnd(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RecurrenceEnd)} 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 RecurrenceEnd FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRecurrenceEnd(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecurrenceEnd.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecurrenceEnd.cs new file mode 100644 index 000000000000..a0761463bdff --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecurrenceEnd.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.Developer.LoadTesting +{ + /// Recurrence end model. Either provide numberOfOccurrences if you want recurrence to end after a specified number of occurrences or provide endDate if you want recurrence to end after a specified end date. If both values are provided, a validation error will be thrown indicating that only one field should be provided. If neither value is provided, the recurrence will end when manually ended. + public partial class RecurrenceEnd + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public RecurrenceEnd() + { + } + + /// Initializes a new instance of . + /// Number of occurrences after which the recurrence will end. + /// The date after which the recurrence will end. (RFC 3339 literal format). + /// Keeps track of any properties unknown to the library. + internal RecurrenceEnd(int? numberOfOccurrences, DateTimeOffset? endDateTime, IDictionary serializedAdditionalRawData) + { + NumberOfOccurrences = numberOfOccurrences; + EndDateTime = endDateTime; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Number of occurrences after which the recurrence will end. + public int? NumberOfOccurrences { get; set; } + /// The date after which the recurrence will end. (RFC 3339 literal format). + public DateTimeOffset? EndDateTime { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecurrenceStatus.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecurrenceStatus.Serialization.cs new file mode 100644 index 000000000000..d2da6aad71e9 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecurrenceStatus.Serialization.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class RecurrenceStatus : 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(RecurrenceStatus)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(RemainingOccurrences)) + { + writer.WritePropertyName("remainingOccurrences"u8); + writer.WriteNumberValue(RemainingOccurrences.Value); + } + if (Optional.IsCollectionDefined(NextScheduledDateTimes)) + { + writer.WritePropertyName("nextScheduledDateTimes"u8); + writer.WriteStartArray(); + foreach (var item in NextScheduledDateTimes) + { + writer.WriteStringValue(item, "O"); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RecurrenceStatus 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(RecurrenceStatus)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRecurrenceStatus(document.RootElement, options); + } + + internal static RecurrenceStatus DeserializeRecurrenceStatus(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? remainingOccurrences = default; + IReadOnlyList nextScheduledDateTimes = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("remainingOccurrences"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + remainingOccurrences = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("nextScheduledDateTimes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetDateTimeOffset("O")); + } + nextScheduledDateTimes = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RecurrenceStatus(remainingOccurrences, nextScheduledDateTimes ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RecurrenceStatus)} does not support writing '{options.Format}' format."); + } + } + + RecurrenceStatus 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 DeserializeRecurrenceStatus(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RecurrenceStatus)} 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 RecurrenceStatus FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRecurrenceStatus(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecurrenceStatus.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecurrenceStatus.cs new file mode 100644 index 000000000000..19acfb9c7750 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecurrenceStatus.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Actual state of the recurrence for the trigger. + public partial class RecurrenceStatus + { + /// + /// 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 RecurrenceStatus() + { + NextScheduledDateTimes = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The number of occurrences remaining for the trigger. Null if recurrence end has end date instead of number of occurrences. + /// The next three execution times of the trigger. (RFC 3339 literal format). + /// Keeps track of any properties unknown to the library. + internal RecurrenceStatus(int? remainingOccurrences, IReadOnlyList nextScheduledDateTimes, IDictionary serializedAdditionalRawData) + { + RemainingOccurrences = remainingOccurrences; + NextScheduledDateTimes = nextScheduledDateTimes; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The number of occurrences remaining for the trigger. Null if recurrence end has end date instead of number of occurrences. + public int? RemainingOccurrences { get; } + /// The next three execution times of the trigger. (RFC 3339 literal format). + public IReadOnlyList NextScheduledDateTimes { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecurrenceWithCron.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecurrenceWithCron.Serialization.cs new file mode 100644 index 000000000000..81d6780a4d3a --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecurrenceWithCron.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class RecurrenceWithCron : 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(RecurrenceWithCron)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("cronExpression"u8); + writer.WriteStringValue(CronExpression); + } + + RecurrenceWithCron 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(RecurrenceWithCron)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRecurrenceWithCron(document.RootElement, options); + } + + internal static RecurrenceWithCron DeserializeRecurrenceWithCron(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string cronExpression = default; + Frequency frequency = default; + RecurrenceEnd recurrenceEnd = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("cronExpression"u8)) + { + cronExpression = property.Value.GetString(); + continue; + } + if (property.NameEquals("frequency"u8)) + { + frequency = new Frequency(property.Value.GetString()); + continue; + } + if (property.NameEquals("recurrenceEnd"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RecurrenceWithCron(frequency, recurrenceEnd, serializedAdditionalRawData, cronExpression); + } + + 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(RecurrenceWithCron)} does not support writing '{options.Format}' format."); + } + } + + RecurrenceWithCron 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 DeserializeRecurrenceWithCron(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RecurrenceWithCron)} 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 RecurrenceWithCron FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRecurrenceWithCron(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecurrenceWithCron.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecurrenceWithCron.cs new file mode 100644 index 000000000000..004d59995661 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RecurrenceWithCron.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Recurrence is set based on cron expression. + public partial class RecurrenceWithCron : Recurrence + { + /// Initializes a new instance of . + /// Cron expression for the recurrence. + /// is null. + public RecurrenceWithCron(string cronExpression) + { + Argument.AssertNotNull(cronExpression, nameof(cronExpression)); + + Frequency = Frequency.Cron; + CronExpression = cronExpression; + } + + /// Initializes a new instance of . + /// Frequency of the recurrence. + /// Recurrence end model. You can specify the end either by providing a numberOfOccurrences (which will end the recurrence after the specified number of occurrences) or by providing an endDateTime (which will end the recurrence after the specified date). If neither value is provided, the recurrence will continue until it is manually ended. However, if both values are provided, an error will be thrown. + /// Keeps track of any properties unknown to the library. + /// Cron expression for the recurrence. + internal RecurrenceWithCron(Frequency frequency, RecurrenceEnd recurrenceEnd, IDictionary serializedAdditionalRawData, string cronExpression) : base(frequency, recurrenceEnd, serializedAdditionalRawData) + { + CronExpression = cronExpression; + } + + /// Initializes a new instance of for deserialization. + internal RecurrenceWithCron() + { + } + + /// Cron expression for the recurrence. + public string CronExpression { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RegionalConfiguration.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RegionalConfiguration.Serialization.cs new file mode 100644 index 000000000000..a24d632ffe3a --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RegionalConfiguration.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class RegionalConfiguration : 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(RegionalConfiguration)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("engineInstances"u8); + writer.WriteNumberValue(EngineInstances); + writer.WritePropertyName("region"u8); + writer.WriteStringValue(Region); + 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 + } + } + } + + RegionalConfiguration 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(RegionalConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRegionalConfiguration(document.RootElement, options); + } + + internal static RegionalConfiguration DeserializeRegionalConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int engineInstances = default; + AzureLocation region = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("engineInstances"u8)) + { + engineInstances = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("region"u8)) + { + region = new AzureLocation(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RegionalConfiguration(engineInstances, region, 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(RegionalConfiguration)} does not support writing '{options.Format}' format."); + } + } + + RegionalConfiguration 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 DeserializeRegionalConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RegionalConfiguration)} 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 RegionalConfiguration FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRegionalConfiguration(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/RegionalConfiguration.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RegionalConfiguration.cs new file mode 100644 index 000000000000..fd742c09e86f --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RegionalConfiguration.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + /// Region distribution configuration for the load test. + public partial class RegionalConfiguration + { + /// + /// 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 number of engine instances to execute load test in specified region. Supported values are in range of 1-400. + /// + /// Azure region name. + /// The region name should of format accepted by ARM, and should be a region supported by Azure Load Testing. For example, East US should be passed as "eastus". + /// The region name must match one of the strings in the "Name" column returned from running the "az account list-locations -o table" Azure CLI command. + /// + public RegionalConfiguration(int engineInstances, AzureLocation region) + { + EngineInstances = engineInstances; + Region = region; + } + + /// Initializes a new instance of . + /// The number of engine instances to execute load test in specified region. Supported values are in range of 1-400. + /// + /// Azure region name. + /// The region name should of format accepted by ARM, and should be a region supported by Azure Load Testing. For example, East US should be passed as "eastus". + /// The region name must match one of the strings in the "Name" column returned from running the "az account list-locations -o table" Azure CLI command. + /// + /// Keeps track of any properties unknown to the library. + internal RegionalConfiguration(int engineInstances, AzureLocation region, IDictionary serializedAdditionalRawData) + { + EngineInstances = engineInstances; + Region = region; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RegionalConfiguration() + { + } + + /// The number of engine instances to execute load test in specified region. Supported values are in range of 1-400. + public int EngineInstances { get; set; } + /// + /// Azure region name. + /// The region name should of format accepted by ARM, and should be a region supported by Azure Load Testing. For example, East US should be passed as "eastus". + /// The region name must match one of the strings in the "Name" column returned from running the "az account list-locations -o table" Azure CLI command. + /// + public AzureLocation Region { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RequestDataLevel.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RequestDataLevel.cs new file mode 100644 index 000000000000..b55aa822172b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/RequestDataLevel.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Request data collection level for test run. + public readonly partial struct RequestDataLevel : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RequestDataLevel(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NONEValue = "NONE"; + private const string ERRORSValue = "ERRORS"; + + /// No request data will be collected. + public static RequestDataLevel NONE { get; } = new RequestDataLevel(NONEValue); + /// Request data will be collected in case of failed requests. + public static RequestDataLevel ERRORS { get; } = new RequestDataLevel(ERRORSValue); + /// Determines if two values are the same. + public static bool operator ==(RequestDataLevel left, RequestDataLevel right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RequestDataLevel left, RequestDataLevel right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator RequestDataLevel(string value) => new RequestDataLevel(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RequestDataLevel other && Equals(other); + /// + public bool Equals(RequestDataLevel 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/ResourceKind.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ResourceKind.cs new file mode 100644 index 000000000000..10af6895b2ec --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ResourceKind.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Kind of the resource on which test profile is created. + internal readonly partial struct ResourceKind : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ResourceKind(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FunctionsFlexConsumptionValue = "FunctionsFlexConsumption"; + + /// Resource is a Azure FunctionApp on Flex Consumption Plan. + public static ResourceKind FunctionsFlexConsumption { get; } = new ResourceKind(FunctionsFlexConsumptionValue); + /// Determines if two values are the same. + public static bool operator ==(ResourceKind left, ResourceKind right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ResourceKind left, ResourceKind right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ResourceKind(string value) => new ResourceKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ResourceKind other && Equals(other); + /// + public bool Equals(ResourceKind 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/ResourceMetric.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ResourceMetric.Serialization.cs new file mode 100644 index 000000000000..4c0ed72b3c30 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ResourceMetric.Serialization.cs @@ -0,0 +1,216 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class ResourceMetric : 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(ResourceMetric)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + writer.WritePropertyName("resourceId"u8); + writer.WriteStringValue(ResourceId); + writer.WritePropertyName("metricNamespace"u8); + writer.WriteStringValue(MetricNamespace); + if (Optional.IsDefined(DisplayDescription)) + { + writer.WritePropertyName("displayDescription"u8); + writer.WriteStringValue(DisplayDescription); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("aggregation"u8); + writer.WriteStringValue(Aggregation); + if (Optional.IsDefined(Unit)) + { + writer.WritePropertyName("unit"u8); + writer.WriteStringValue(Unit); + } + writer.WritePropertyName("resourceType"u8); + writer.WriteStringValue(ResourceType); + 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 + } + } + } + + ResourceMetric 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(ResourceMetric)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceMetric(document.RootElement, options); + } + + internal static ResourceMetric DeserializeResourceMetric(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + ResourceIdentifier resourceId = default; + string metricNamespace = default; + string displayDescription = default; + string name = default; + string aggregation = default; + string unit = default; + string resourceType = 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("resourceId"u8)) + { + resourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("metricNamespace"u8)) + { + metricNamespace = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayDescription"u8)) + { + displayDescription = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("aggregation"u8)) + { + aggregation = property.Value.GetString(); + continue; + } + if (property.NameEquals("unit"u8)) + { + unit = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceType"u8)) + { + resourceType = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ResourceMetric( + id, + resourceId, + metricNamespace, + displayDescription, + name, + aggregation, + unit, + resourceType, + 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(ResourceMetric)} does not support writing '{options.Format}' format."); + } + } + + ResourceMetric 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 DeserializeResourceMetric(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceMetric)} 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 ResourceMetric FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeResourceMetric(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/ResourceMetric.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ResourceMetric.cs new file mode 100644 index 000000000000..5059dad8af80 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ResourceMetric.cs @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + /// + /// Associated metric definition for particular metrics of the azure resource ( + /// Refer : + /// https://learn.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). + /// + public partial class ResourceMetric + { + /// + /// 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 . + /// Azure resource id. + /// Metric name space. + /// The invariant value of metric name. + /// Metric aggregation. + /// Azure resource type. + /// , , , or is null. + public ResourceMetric(ResourceIdentifier resourceId, string metricNamespace, string name, string aggregation, string resourceType) + { + Argument.AssertNotNull(resourceId, nameof(resourceId)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(aggregation, nameof(aggregation)); + Argument.AssertNotNull(resourceType, nameof(resourceType)); + + ResourceId = resourceId; + MetricNamespace = metricNamespace; + Name = name; + Aggregation = aggregation; + ResourceType = resourceType; + } + + /// Initializes a new instance of . + /// Unique name for metric. + /// Azure resource id. + /// Metric name space. + /// Metric description. + /// The invariant value of metric name. + /// Metric aggregation. + /// Metric unit. + /// Azure resource type. + /// Keeps track of any properties unknown to the library. + internal ResourceMetric(string id, ResourceIdentifier resourceId, string metricNamespace, string displayDescription, string name, string aggregation, string unit, string resourceType, IDictionary serializedAdditionalRawData) + { + Id = id; + ResourceId = resourceId; + MetricNamespace = metricNamespace; + DisplayDescription = displayDescription; + Name = name; + Aggregation = aggregation; + Unit = unit; + ResourceType = resourceType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ResourceMetric() + { + } + + /// Unique name for metric. + public string Id { get; } + /// Azure resource id. + public ResourceIdentifier ResourceId { get; set; } + /// Metric name space. + public string MetricNamespace { get; set; } + /// Metric description. + public string DisplayDescription { get; set; } + /// The invariant value of metric name. + public string Name { get; set; } + /// Metric aggregation. + public string Aggregation { get; set; } + /// Metric unit. + public string Unit { get; set; } + /// Azure resource type. + public string ResourceType { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ScheduleTestsTrigger.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ScheduleTestsTrigger.Serialization.cs new file mode 100644 index 000000000000..efe54ab6e14c --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ScheduleTestsTrigger.Serialization.cs @@ -0,0 +1,274 @@ +// 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.Developer.LoadTesting +{ + public partial class ScheduleTestsTrigger : 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(ScheduleTestsTrigger)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("testIds"u8); + writer.WriteStartArray(); + foreach (var item in TestIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (Optional.IsDefined(StartDateTime)) + { + writer.WritePropertyName("startDateTime"u8); + writer.WriteStringValue(StartDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(RecurrenceStatus)) + { + writer.WritePropertyName("recurrenceStatus"u8); + writer.WriteObjectValue(RecurrenceStatus, options); + } + if (Optional.IsDefined(Recurrence)) + { + writer.WritePropertyName("recurrence"u8); + writer.WriteObjectValue(Recurrence, options); + } + } + + ScheduleTestsTrigger 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(ScheduleTestsTrigger)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeScheduleTestsTrigger(document.RootElement, options); + } + + internal static ScheduleTestsTrigger DeserializeScheduleTestsTrigger(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList testIds = default; + DateTimeOffset? startDateTime = default; + RecurrenceStatus recurrenceStatus = default; + Recurrence recurrence = default; + string triggerId = default; + string displayName = default; + string description = default; + TriggerType kind = default; + TriggerState? state = default; + StateDetails stateDetails = default; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("testIds"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + testIds = array; + continue; + } + if (property.NameEquals("startDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("recurrenceStatus"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + recurrenceStatus = RecurrenceStatus.DeserializeRecurrenceStatus(property.Value, options); + continue; + } + if (property.NameEquals("recurrence"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + recurrence = Recurrence.DeserializeRecurrence(property.Value, options); + continue; + } + if (property.NameEquals("triggerId"u8)) + { + triggerId = 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("kind"u8)) + { + kind = new TriggerType(property.Value.GetString()); + continue; + } + if (property.NameEquals("state"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + state = new TriggerState(property.Value.GetString()); + continue; + } + if (property.NameEquals("stateDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + stateDetails = StateDetails.DeserializeStateDetails(property.Value, options); + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ScheduleTestsTrigger( + triggerId, + displayName, + description, + kind, + state, + stateDetails, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData, + testIds, + startDateTime, + recurrenceStatus, + recurrence); + } + + 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(ScheduleTestsTrigger)} does not support writing '{options.Format}' format."); + } + } + + ScheduleTestsTrigger 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 DeserializeScheduleTestsTrigger(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ScheduleTestsTrigger)} 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 ScheduleTestsTrigger FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeScheduleTestsTrigger(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/ScheduleTestsTrigger.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ScheduleTestsTrigger.cs new file mode 100644 index 000000000000..17426218b783 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/ScheduleTestsTrigger.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.Developer.LoadTesting +{ + /// ScheduleTestsTrigger model. + public partial class ScheduleTestsTrigger : Trigger + { + /// Initializes a new instance of . + /// The name of the trigger. + /// The test id of test to be triggered by this schedule trigger. Currently only one test is supported for a trigger. + /// or is null. + public ScheduleTestsTrigger(string displayName, IEnumerable testIds) : base(displayName) + { + Argument.AssertNotNull(displayName, nameof(displayName)); + Argument.AssertNotNull(testIds, nameof(testIds)); + + Kind = TriggerType.ScheduleTestsTrigger; + TestIds = testIds.ToList(); + } + + /// Initializes a new instance of . + /// The unique identifier of the trigger. + /// The name of the trigger. + /// The description of the trigger. + /// The type of the trigger. + /// The current state of the trigger. + /// Details of current state of the trigger. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + /// The test id of test to be triggered by this schedule trigger. Currently only one test is supported for a trigger. + /// Start date time of the trigger in UTC timezone. (RFC 3339 literal format). + /// + /// + /// Recurrence details of the trigger. Null if schedule is not recurring. + /// 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 . + /// + internal ScheduleTestsTrigger(string triggerId, string displayName, string description, TriggerType kind, TriggerState? state, StateDetails stateDetails, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData, IList testIds, DateTimeOffset? startDateTime, RecurrenceStatus recurrenceStatus, Recurrence recurrence) : base(triggerId, displayName, description, kind, state, stateDetails, createdDateTime, createdBy, lastModifiedDateTime, lastModifiedBy, serializedAdditionalRawData) + { + TestIds = testIds; + StartDateTime = startDateTime; + RecurrenceStatus = recurrenceStatus; + Recurrence = recurrence; + } + + /// Initializes a new instance of for deserialization. + internal ScheduleTestsTrigger() + { + } + + /// The test id of test to be triggered by this schedule trigger. Currently only one test is supported for a trigger. + public IList TestIds { get; } + /// Start date time of the trigger in UTC timezone. (RFC 3339 literal format). + public DateTimeOffset? StartDateTime { get; set; } + /// Gets the recurrence status. + public RecurrenceStatus RecurrenceStatus { get; } + /// + /// Recurrence details of the trigger. Null if schedule is not recurring. + /// 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 Recurrence Recurrence { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/SecretType.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/SecretType.cs new file mode 100644 index 000000000000..6937c671909b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/SecretType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Types of secrets supported. + public readonly partial struct SecretType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public SecretType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string KeyVaultSecretUriValue = "AKV_SECRET_URI"; + private const string SecretValueValue = "SECRET_VALUE"; + + /// If the secret is stored in an Azure Key Vault. + public static SecretType KeyVaultSecretUri { get; } = new SecretType(KeyVaultSecretUriValue); + /// If the secret value provided as plain text. + public static SecretType SecretValue { get; } = new SecretType(SecretValueValue); + /// Determines if two values are the same. + public static bool operator ==(SecretType left, SecretType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(SecretType left, SecretType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator SecretType(string value) => new SecretType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SecretType other && Equals(other); + /// + public bool Equals(SecretType 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/StateDetails.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/StateDetails.Serialization.cs new file mode 100644 index 000000000000..9e48858fb952 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/StateDetails.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class StateDetails : 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(StateDetails)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Message)) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + 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 + } + } + } + + StateDetails 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(StateDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStateDetails(document.RootElement, options); + } + + internal static StateDetails DeserializeStateDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string message = 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 (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new StateDetails(message, 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(StateDetails)} does not support writing '{options.Format}' format."); + } + } + + StateDetails 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 DeserializeStateDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StateDetails)} 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 StateDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeStateDetails(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/StateDetails.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/StateDetails.cs new file mode 100644 index 000000000000..fa8f6c783e0b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/StateDetails.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// State details of the trigger. + public partial class StateDetails + { + /// + /// 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 StateDetails() + { + } + + /// Initializes a new instance of . + /// The error message if the trigger is in disabled state. + /// Keeps track of any properties unknown to the library. + internal StateDetails(string message, IDictionary serializedAdditionalRawData) + { + Message = message; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The error message if the trigger is in disabled state. + public string Message { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TargetResourceConfigurations.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TargetResourceConfigurations.Serialization.cs new file mode 100644 index 000000000000..bf25b7a5c885 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TargetResourceConfigurations.Serialization.cs @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + [PersistableModelProxy(typeof(UnknownTargetResourceConfigurations))] + public partial class TargetResourceConfigurations : 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(TargetResourceConfigurations)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.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 + } + } + } + + TargetResourceConfigurations 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(TargetResourceConfigurations)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTargetResourceConfigurations(document.RootElement, options); + } + + internal static TargetResourceConfigurations DeserializeTargetResourceConfigurations(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("kind", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "FunctionsFlexConsumption": return FunctionFlexConsumptionTargetResourceConfigurations.DeserializeFunctionFlexConsumptionTargetResourceConfigurations(element, options); + } + } + return UnknownTargetResourceConfigurations.DeserializeUnknownTargetResourceConfigurations(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(TargetResourceConfigurations)} does not support writing '{options.Format}' format."); + } + } + + TargetResourceConfigurations 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 DeserializeTargetResourceConfigurations(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TargetResourceConfigurations)} 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 TargetResourceConfigurations FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTargetResourceConfigurations(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TargetResourceConfigurations.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TargetResourceConfigurations.cs new file mode 100644 index 000000000000..653c885e35ba --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TargetResourceConfigurations.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.Developer.LoadTesting +{ + /// + /// Configurations of a target resource. This varies with the kind of resource. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + public abstract partial class TargetResourceConfigurations + { + /// + /// 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 TargetResourceConfigurations() + { + } + + /// Initializes a new instance of . + /// Kind of the resource for which the configurations apply. + /// Keeps track of any properties unknown to the library. + internal TargetResourceConfigurations(ResourceKind kind, IDictionary serializedAdditionalRawData) + { + Kind = kind; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Kind of the resource for which the configurations apply. + internal ResourceKind Kind { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestAppComponents.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestAppComponents.Serialization.cs new file mode 100644 index 000000000000..72a8ccda371c --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestAppComponents.Serialization.cs @@ -0,0 +1,223 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class TestAppComponents : 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(TestAppComponents)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("components"u8); + writer.WriteStartObject(); + foreach (var item in Components) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + if (options.Format != "W" && Optional.IsDefined(TestId)) + { + writer.WritePropertyName("testId"u8); + writer.WriteStringValue(TestId); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedDateTime)) + { + writer.WritePropertyName("lastModifiedDateTime"u8); + writer.WriteStringValue(LastModifiedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedBy)) + { + writer.WritePropertyName("lastModifiedBy"u8); + writer.WriteStringValue(LastModifiedBy); + } + 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 + } + } + } + + TestAppComponents 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(TestAppComponents)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestAppComponents(document.RootElement, options); + } + + internal static TestAppComponents DeserializeTestAppComponents(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary components = default; + string testId = default; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("components"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, LoadTestingAppComponent.DeserializeLoadTestingAppComponent(property0.Value, options)); + } + components = dictionary; + continue; + } + if (property.NameEquals("testId"u8)) + { + testId = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestAppComponents( + components, + testId, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + 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(TestAppComponents)} does not support writing '{options.Format}' format."); + } + } + + TestAppComponents 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 DeserializeTestAppComponents(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestAppComponents)} 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 TestAppComponents FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestAppComponents(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestAppComponents.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestAppComponents.cs new file mode 100644 index 000000000000..3e7e8a90b428 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestAppComponents.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Test app components. + public partial class TestAppComponents + { + /// + /// 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 . + /// + /// Azure resource collection { resource id (fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + /// : resource object } + /// + /// is null. + public TestAppComponents(IDictionary components) + { + Argument.AssertNotNull(components, nameof(components)); + + Components = components; + } + + /// Initializes a new instance of . + /// + /// Azure resource collection { resource id (fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + /// : resource object } + /// + /// Test identifier. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal TestAppComponents(IDictionary components, string testId, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + { + Components = components; + TestId = testId; + CreatedDateTime = createdDateTime; + CreatedBy = createdBy; + LastModifiedDateTime = lastModifiedDateTime; + LastModifiedBy = lastModifiedBy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TestAppComponents() + { + } + + /// + /// Azure resource collection { resource id (fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + /// : resource object } + /// + public IDictionary Components { get; } + /// Test identifier. + public string TestId { get; } + /// The creation datetime(RFC 3339 literal format). + public DateTimeOffset? CreatedDateTime { get; } + /// The user that created. + public string CreatedBy { get; } + /// The last Modified datetime(RFC 3339 literal format). + public DateTimeOffset? LastModifiedDateTime { get; } + /// The user that last modified. + public string LastModifiedBy { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestCertificate.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestCertificate.Serialization.cs new file mode 100644 index 000000000000..d496bda39faf --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestCertificate.Serialization.cs @@ -0,0 +1,171 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class TestCertificate : 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(TestCertificate)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + } + if (Optional.IsDefined(CertificateKind)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(CertificateKind.Value.ToString()); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestCertificate 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(TestCertificate)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestCertificate(document.RootElement, options); + } + + internal static TestCertificate DeserializeTestCertificate(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string value = default; + CertificateType? type = default; + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + value = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + type = new CertificateType(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestCertificate(value, type, name, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestCertificate)} does not support writing '{options.Format}' format."); + } + } + + TestCertificate 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 DeserializeTestCertificate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestCertificate)} 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 TestCertificate FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestCertificate(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestCertificate.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestCertificate.cs new file mode 100644 index 000000000000..52ba75d2b6ca --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestCertificate.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Certificates metadata. + public partial class TestCertificate + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TestCertificate() + { + } + + /// Initializes a new instance of . + /// The value of the certificate for respective type. + /// Type of certificate. + /// Name of the certificate. + /// Keeps track of any properties unknown to the library. + internal TestCertificate(string value, CertificateType? certificateKind, string name, IDictionary serializedAdditionalRawData) + { + Value = value; + CertificateKind = certificateKind; + Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The value of the certificate for respective type. + public string Value { get; set; } + /// Type of certificate. + public CertificateType? CertificateKind { get; set; } + /// Name of the certificate. + public string Name { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestFileInfo.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestFileInfo.Serialization.cs new file mode 100644 index 000000000000..55f0ce83a72b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestFileInfo.Serialization.cs @@ -0,0 +1,220 @@ +// 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.Developer.LoadTesting +{ + public partial class TestFileInfo : 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(TestFileInfo)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("fileName"u8); + writer.WriteStringValue(FileName); + if (options.Format != "W" && Optional.IsDefined(Uri)) + { + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Uri.AbsoluteUri); + } + if (options.Format != "W" && Optional.IsDefined(FileType)) + { + writer.WritePropertyName("fileType"u8); + writer.WriteStringValue(FileType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ExpiresOn)) + { + writer.WritePropertyName("expireDateTime"u8); + writer.WriteStringValue(ExpiresOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ValidationStatus)) + { + writer.WritePropertyName("validationStatus"u8); + writer.WriteStringValue(ValidationStatus.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ValidationFailureDetails)) + { + writer.WritePropertyName("validationFailureDetails"u8); + writer.WriteStringValue(ValidationFailureDetails); + } + 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 + } + } + } + + TestFileInfo 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(TestFileInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestFileInfo(document.RootElement, options); + } + + internal static TestFileInfo DeserializeTestFileInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileName = default; + Uri url = default; + LoadTestingFileType? fileType = default; + DateTimeOffset? expireDateTime = default; + FileValidationStatus? validationStatus = default; + string validationFailureDetails = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("fileName"u8)) + { + fileName = property.Value.GetString(); + continue; + } + if (property.NameEquals("url"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + url = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("fileType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fileType = new LoadTestingFileType(property.Value.GetString()); + continue; + } + if (property.NameEquals("expireDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expireDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("validationStatus"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + validationStatus = new FileValidationStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("validationFailureDetails"u8)) + { + validationFailureDetails = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestFileInfo( + fileName, + url, + fileType, + expireDateTime, + validationStatus, + validationFailureDetails, + 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(TestFileInfo)} does not support writing '{options.Format}' format."); + } + } + + TestFileInfo 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 DeserializeTestFileInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestFileInfo)} 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 TestFileInfo FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestFileInfo(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestFileInfo.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestFileInfo.cs new file mode 100644 index 000000000000..f8565ac4492c --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestFileInfo.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Test file info. + public partial class TestFileInfo + { + /// + /// 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 . + /// Name of the file. + /// is null. + internal TestFileInfo(string fileName) + { + Argument.AssertNotNull(fileName, nameof(fileName)); + + FileName = fileName; + } + + /// Initializes a new instance of . + /// Name of the file. + /// File URL. + /// File type. + /// Expiry time of the file (RFC 3339 literal format). + /// Validation status of the file. + /// Validation failure error details. + /// Keeps track of any properties unknown to the library. + internal TestFileInfo(string fileName, Uri uri, LoadTestingFileType? fileType, DateTimeOffset? expiresOn, FileValidationStatus? validationStatus, string validationFailureDetails, IDictionary serializedAdditionalRawData) + { + FileName = fileName; + Uri = uri; + FileType = fileType; + ExpiresOn = expiresOn; + ValidationStatus = validationStatus; + ValidationFailureDetails = validationFailureDetails; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TestFileInfo() + { + } + + /// Name of the file. + public string FileName { get; } + /// File URL. + public Uri Uri { get; } + /// File type. + public LoadTestingFileType? FileType { get; } + /// Expiry time of the file (RFC 3339 literal format). + public DateTimeOffset? ExpiresOn { get; } + /// Validation status of the file. + public FileValidationStatus? ValidationStatus { get; } + /// Validation failure error details. + public string ValidationFailureDetails { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestInputArtifacts.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestInputArtifacts.Serialization.cs new file mode 100644 index 000000000000..8a4544b32a89 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestInputArtifacts.Serialization.cs @@ -0,0 +1,241 @@ +// 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.Developer.LoadTesting +{ + public partial class TestInputArtifacts : 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(TestInputArtifacts)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ConfigFileInfo)) + { + writer.WritePropertyName("configFileInfo"u8); + writer.WriteObjectValue(ConfigFileInfo, options); + } + if (Optional.IsDefined(TestScriptFileInfo)) + { + writer.WritePropertyName("testScriptFileInfo"u8); + writer.WriteObjectValue(TestScriptFileInfo, options); + } + if (Optional.IsDefined(UserPropertyFileInfo)) + { + writer.WritePropertyName("userPropFileInfo"u8); + writer.WriteObjectValue(UserPropertyFileInfo, options); + } + if (Optional.IsDefined(InputArtifactsZipFileInfo)) + { + writer.WritePropertyName("inputArtifactsZipFileInfo"u8); + writer.WriteObjectValue(InputArtifactsZipFileInfo, options); + } + if (Optional.IsDefined(UrlTestConfigFileInfo)) + { + writer.WritePropertyName("urlTestConfigFileInfo"u8); + writer.WriteObjectValue(UrlTestConfigFileInfo, options); + } + if (options.Format != "W" && Optional.IsCollectionDefined(AdditionalFileInfo)) + { + writer.WritePropertyName("additionalFileInfo"u8); + writer.WriteStartArray(); + foreach (var item in AdditionalFileInfo) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestInputArtifacts 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(TestInputArtifacts)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestInputArtifacts(document.RootElement, options); + } + + internal static TestInputArtifacts DeserializeTestInputArtifacts(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TestFileInfo configFileInfo = default; + TestFileInfo testScriptFileInfo = default; + TestFileInfo userPropFileInfo = default; + TestFileInfo inputArtifactsZipFileInfo = default; + TestFileInfo urlTestConfigFileInfo = default; + IReadOnlyList additionalFileInfo = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("configFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + configFileInfo = TestFileInfo.DeserializeTestFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("testScriptFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + testScriptFileInfo = TestFileInfo.DeserializeTestFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("userPropFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + userPropFileInfo = TestFileInfo.DeserializeTestFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("inputArtifactsZipFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + inputArtifactsZipFileInfo = TestFileInfo.DeserializeTestFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("urlTestConfigFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + urlTestConfigFileInfo = TestFileInfo.DeserializeTestFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("additionalFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TestFileInfo.DeserializeTestFileInfo(item, options)); + } + additionalFileInfo = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestInputArtifacts( + configFileInfo, + testScriptFileInfo, + userPropFileInfo, + inputArtifactsZipFileInfo, + urlTestConfigFileInfo, + additionalFileInfo ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestInputArtifacts)} does not support writing '{options.Format}' format."); + } + } + + TestInputArtifacts 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 DeserializeTestInputArtifacts(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestInputArtifacts)} 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 TestInputArtifacts FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestInputArtifacts(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestInputArtifacts.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestInputArtifacts.cs new file mode 100644 index 000000000000..f59c5a94183f --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestInputArtifacts.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.Developer.LoadTesting +{ + /// The input artifacts for the test. + public partial class TestInputArtifacts + { + /// + /// 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 TestInputArtifacts() + { + AdditionalFileInfo = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The load test YAML file that contains the the test configuration. + /// The test script file for the test run. + /// The user properties file. + /// The zip file with all input artifacts. + /// The config json file for url based test. + /// Additional supported files for the test run. + /// Keeps track of any properties unknown to the library. + internal TestInputArtifacts(TestFileInfo configFileInfo, TestFileInfo testScriptFileInfo, TestFileInfo userPropertyFileInfo, TestFileInfo inputArtifactsZipFileInfo, TestFileInfo urlTestConfigFileInfo, IReadOnlyList additionalFileInfo, IDictionary serializedAdditionalRawData) + { + ConfigFileInfo = configFileInfo; + TestScriptFileInfo = testScriptFileInfo; + UserPropertyFileInfo = userPropertyFileInfo; + InputArtifactsZipFileInfo = inputArtifactsZipFileInfo; + UrlTestConfigFileInfo = urlTestConfigFileInfo; + AdditionalFileInfo = additionalFileInfo; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The load test YAML file that contains the the test configuration. + public TestFileInfo ConfigFileInfo { get; } + /// The test script file for the test run. + public TestFileInfo TestScriptFileInfo { get; } + /// The user properties file. + public TestFileInfo UserPropertyFileInfo { get; } + /// The zip file with all input artifacts. + public TestFileInfo InputArtifactsZipFileInfo { get; } + /// The config json file for url based test. + public TestFileInfo UrlTestConfigFileInfo { get; } + /// Additional supported files for the test run. + public IReadOnlyList AdditionalFileInfo { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfile.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfile.Serialization.cs new file mode 100644 index 000000000000..df38fd2db79f --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfile.Serialization.cs @@ -0,0 +1,271 @@ +// 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.Developer.LoadTesting +{ + public partial class TestProfile : 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(TestProfile)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("testProfileId"u8); + writer.WriteStringValue(TestProfileId); + } + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(TestId)) + { + writer.WritePropertyName("testId"u8); + writer.WriteStringValue(TestId); + } + if (Optional.IsDefined(TargetResourceId)) + { + writer.WritePropertyName("targetResourceId"u8); + writer.WriteStringValue(TargetResourceId); + } + if (Optional.IsDefined(TargetResourceConfigurations)) + { + writer.WritePropertyName("targetResourceConfigurations"u8); + writer.WriteObjectValue(TargetResourceConfigurations, options); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedDateTime)) + { + writer.WritePropertyName("lastModifiedDateTime"u8); + writer.WriteStringValue(LastModifiedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedBy)) + { + writer.WritePropertyName("lastModifiedBy"u8); + writer.WriteStringValue(LastModifiedBy); + } + 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 + } + } + } + + TestProfile 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(TestProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestProfile(document.RootElement, options); + } + + internal static TestProfile DeserializeTestProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string testProfileId = default; + string displayName = default; + string description = default; + string testId = default; + ResourceIdentifier targetResourceId = default; + TargetResourceConfigurations targetResourceConfigurations = default; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("testProfileId"u8)) + { + testProfileId = 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("testId"u8)) + { + testId = property.Value.GetString(); + continue; + } + if (property.NameEquals("targetResourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("targetResourceConfigurations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetResourceConfigurations = TargetResourceConfigurations.DeserializeTargetResourceConfigurations(property.Value, options); + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestProfile( + testProfileId, + displayName, + description, + testId, + targetResourceId, + targetResourceConfigurations, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + 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(TestProfile)} does not support writing '{options.Format}' format."); + } + } + + TestProfile 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 DeserializeTestProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestProfile)} 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 TestProfile FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestProfile(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfile.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfile.cs new file mode 100644 index 000000000000..1148abffddfd --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfile.cs @@ -0,0 +1,110 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + /// The Test Profile Model. A Test Profile resource enables you to set up a test profile which contains various configurations for a supported resource type and a load test to execute on that resource. + public partial class TestProfile + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TestProfile() + { + } + + /// Initializes a new instance of . + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Display name of the test profile. + /// Description for the test profile. + /// Associated test ID for the test profile. This property is required for creating a Test Profile and it's not allowed to be updated. + /// Target resource ID on which the test profile is created. This property is required for creating a Test Profile and it's not allowed to be updated. + /// + /// Configurations of the target resource on which testing would be done. + /// 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 . + /// + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal TestProfile(string testProfileId, string displayName, string description, string testId, ResourceIdentifier targetResourceId, TargetResourceConfigurations targetResourceConfigurations, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + { + TestProfileId = testProfileId; + DisplayName = displayName; + Description = description; + TestId = testId; + TargetResourceId = targetResourceId; + TargetResourceConfigurations = targetResourceConfigurations; + CreatedDateTime = createdDateTime; + CreatedBy = createdBy; + LastModifiedDateTime = lastModifiedDateTime; + LastModifiedBy = lastModifiedBy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + public string TestProfileId { get; } + /// Display name of the test profile. + public string DisplayName { get; set; } + /// Description for the test profile. + public string Description { get; set; } + /// Associated test ID for the test profile. This property is required for creating a Test Profile and it's not allowed to be updated. + public string TestId { get; set; } + /// Target resource ID on which the test profile is created. This property is required for creating a Test Profile and it's not allowed to be updated. + public ResourceIdentifier TargetResourceId { get; set; } + /// + /// Configurations of the target resource on which testing would be done. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + public TargetResourceConfigurations TargetResourceConfigurations { get; set; } + /// The creation datetime(RFC 3339 literal format). + public DateTimeOffset? CreatedDateTime { get; } + /// The user that created. + public string CreatedBy { get; } + /// The last Modified datetime(RFC 3339 literal format). + public DateTimeOffset? LastModifiedDateTime { get; } + /// The user that last modified. + public string LastModifiedBy { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfileRun.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfileRun.Serialization.cs new file mode 100644 index 000000000000..68b2853e792b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfileRun.Serialization.cs @@ -0,0 +1,414 @@ +// 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.Developer.LoadTesting +{ + public partial class TestProfileRun : 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(TestProfileRun)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("testProfileRunId"u8); + writer.WriteStringValue(TestProfileRunId); + } + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(TestProfileId)) + { + writer.WritePropertyName("testProfileId"u8); + writer.WriteStringValue(TestProfileId); + } + if (options.Format != "W" && Optional.IsDefined(TargetResourceId)) + { + writer.WritePropertyName("targetResourceId"u8); + writer.WriteStringValue(TargetResourceId); + } + if (options.Format != "W" && Optional.IsDefined(TargetResourceConfigurations)) + { + writer.WritePropertyName("targetResourceConfigurations"u8); + writer.WriteObjectValue(TargetResourceConfigurations, options); + } + if (options.Format != "W" && Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (options.Format != "W" && Optional.IsCollectionDefined(ErrorDetails)) + { + writer.WritePropertyName("errorDetails"u8); + writer.WriteStartArray(); + foreach (var item in ErrorDetails) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(StartDateTime)) + { + writer.WritePropertyName("startDateTime"u8); + writer.WriteStringValue(StartDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(EndDateTime)) + { + writer.WritePropertyName("endDateTime"u8); + writer.WriteStringValue(EndDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(DurationInSeconds)) + { + writer.WritePropertyName("durationInSeconds"u8); + writer.WriteNumberValue(DurationInSeconds.Value); + } + if (options.Format != "W" && Optional.IsCollectionDefined(TestRunDetails)) + { + writer.WritePropertyName("testRunDetails"u8); + writer.WriteStartObject(); + foreach (var item in TestRunDetails) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Recommendations)) + { + writer.WritePropertyName("recommendations"u8); + writer.WriteStartArray(); + foreach (var item in Recommendations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedDateTime)) + { + writer.WritePropertyName("lastModifiedDateTime"u8); + writer.WriteStringValue(LastModifiedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedBy)) + { + writer.WritePropertyName("lastModifiedBy"u8); + writer.WriteStringValue(LastModifiedBy); + } + 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 + } + } + } + + TestProfileRun 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(TestProfileRun)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestProfileRun(document.RootElement, options); + } + + internal static TestProfileRun DeserializeTestProfileRun(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string testProfileRunId = default; + string displayName = default; + string description = default; + string testProfileId = default; + ResourceIdentifier targetResourceId = default; + TargetResourceConfigurations targetResourceConfigurations = default; + TestProfileRunStatus? status = default; + IReadOnlyList errorDetails = default; + DateTimeOffset? startDateTime = default; + DateTimeOffset? endDateTime = default; + long? durationInSeconds = default; + IReadOnlyDictionary testRunDetails = default; + IReadOnlyList recommendations = default; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("testProfileRunId"u8)) + { + testProfileRunId = 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("testProfileId"u8)) + { + testProfileId = property.Value.GetString(); + continue; + } + if (property.NameEquals("targetResourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("targetResourceConfigurations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetResourceConfigurations = TargetResourceConfigurations.DeserializeTargetResourceConfigurations(property.Value, options); + continue; + } + if (property.NameEquals("status"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new TestProfileRunStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("errorDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(LoadTesting.ErrorDetails.DeserializeErrorDetails(item, options)); + } + errorDetails = array; + continue; + } + if (property.NameEquals("startDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("endDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("durationInSeconds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + durationInSeconds = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("testRunDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, TestRunDetail.DeserializeTestRunDetail(property0.Value, options)); + } + testRunDetails = dictionary; + continue; + } + if (property.NameEquals("recommendations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TestProfileRunRecommendation.DeserializeTestProfileRunRecommendation(item, options)); + } + recommendations = array; + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestProfileRun( + testProfileRunId, + displayName, + description, + testProfileId, + targetResourceId, + targetResourceConfigurations, + status, + errorDetails ?? new ChangeTrackingList(), + startDateTime, + endDateTime, + durationInSeconds, + testRunDetails ?? new ChangeTrackingDictionary(), + recommendations ?? new ChangeTrackingList(), + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + 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(TestProfileRun)} does not support writing '{options.Format}' format."); + } + } + + TestProfileRun 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 DeserializeTestProfileRun(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestProfileRun)} 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 TestProfileRun FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestProfileRun(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfileRun.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfileRun.cs new file mode 100644 index 000000000000..c48bc4d85bdf --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfileRun.cs @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + /// The Test Profile Run Model. Test Profile Run resource enables you to instantiate an already created test profile and run load tests to get recommendations on the optimal configuration for the target resource. + public partial class TestProfileRun + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TestProfileRun() + { + ErrorDetails = new ChangeTrackingList(); + TestRunDetails = new ChangeTrackingDictionary(); + Recommendations = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Display name for the test profile run. + /// The test profile run description. + /// Associated test profile ID for the test profile run. This is required to create a test profile run and can't be updated. + /// Target resource ID on which the test profile run is created. + /// + /// Configurations of the target resource on which the test profile ran. + /// 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 . + /// + /// The test profile run status. + /// Error details if there is any failure in test profile run. These errors are specific to the Test Profile Run. + /// The test profile run start DateTime(RFC 3339 literal format). + /// The test profile run end DateTime(RFC 3339 literal format). + /// Test profile run duration in seconds. + /// + /// Details of the test runs ran as part of the test profile run. + /// Key is the testRunId of the corresponding testRun. + /// + /// Recommendations provided based on a successful test profile run. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal TestProfileRun(string testProfileRunId, string displayName, string description, string testProfileId, ResourceIdentifier targetResourceId, TargetResourceConfigurations targetResourceConfigurations, TestProfileRunStatus? status, IReadOnlyList errorDetails, DateTimeOffset? startDateTime, DateTimeOffset? endDateTime, long? durationInSeconds, IReadOnlyDictionary testRunDetails, IReadOnlyList recommendations, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + { + TestProfileRunId = testProfileRunId; + DisplayName = displayName; + Description = description; + TestProfileId = testProfileId; + TargetResourceId = targetResourceId; + TargetResourceConfigurations = targetResourceConfigurations; + Status = status; + ErrorDetails = errorDetails; + StartDateTime = startDateTime; + EndDateTime = endDateTime; + DurationInSeconds = durationInSeconds; + TestRunDetails = testRunDetails; + Recommendations = recommendations; + CreatedDateTime = createdDateTime; + CreatedBy = createdBy; + LastModifiedDateTime = lastModifiedDateTime; + LastModifiedBy = lastModifiedBy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + public string TestProfileRunId { get; } + /// Display name for the test profile run. + public string DisplayName { get; set; } + /// The test profile run description. + public string Description { get; set; } + /// Associated test profile ID for the test profile run. This is required to create a test profile run and can't be updated. + public string TestProfileId { get; set; } + /// Target resource ID on which the test profile run is created. + public ResourceIdentifier TargetResourceId { get; } + /// + /// Configurations of the target resource on which the test profile ran. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + public TargetResourceConfigurations TargetResourceConfigurations { get; } + /// The test profile run status. + public TestProfileRunStatus? Status { get; } + /// Error details if there is any failure in test profile run. These errors are specific to the Test Profile Run. + public IReadOnlyList ErrorDetails { get; } + /// The test profile run start DateTime(RFC 3339 literal format). + public DateTimeOffset? StartDateTime { get; } + /// The test profile run end DateTime(RFC 3339 literal format). + public DateTimeOffset? EndDateTime { get; } + /// Test profile run duration in seconds. + public long? DurationInSeconds { get; } + /// + /// Details of the test runs ran as part of the test profile run. + /// Key is the testRunId of the corresponding testRun. + /// + public IReadOnlyDictionary TestRunDetails { get; } + /// Recommendations provided based on a successful test profile run. + public IReadOnlyList Recommendations { get; } + /// The creation datetime(RFC 3339 literal format). + public DateTimeOffset? CreatedDateTime { get; } + /// The user that created. + public string CreatedBy { get; } + /// The last Modified datetime(RFC 3339 literal format). + public DateTimeOffset? LastModifiedDateTime { get; } + /// The user that last modified. + public string LastModifiedBy { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfileRunRecommendation.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfileRunRecommendation.Serialization.cs new file mode 100644 index 000000000000..209d9851f173 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfileRunRecommendation.Serialization.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class TestProfileRunRecommendation : 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(TestProfileRunRecommendation)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("category"u8); + writer.WriteStringValue(Category.ToString()); + if (Optional.IsCollectionDefined(Configurations)) + { + writer.WritePropertyName("configurations"u8); + writer.WriteStartArray(); + foreach (var item in Configurations) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestProfileRunRecommendation 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(TestProfileRunRecommendation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestProfileRunRecommendation(document.RootElement, options); + } + + internal static TestProfileRunRecommendation DeserializeTestProfileRunRecommendation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RecommendationCategory category = default; + IReadOnlyList configurations = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("category"u8)) + { + category = new RecommendationCategory(property.Value.GetString()); + continue; + } + if (property.NameEquals("configurations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + configurations = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestProfileRunRecommendation(category, configurations ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestProfileRunRecommendation)} does not support writing '{options.Format}' format."); + } + } + + TestProfileRunRecommendation 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 DeserializeTestProfileRunRecommendation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestProfileRunRecommendation)} 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 TestProfileRunRecommendation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestProfileRunRecommendation(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfileRunRecommendation.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfileRunRecommendation.cs new file mode 100644 index 000000000000..0ffa550c782b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfileRunRecommendation.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.Developer.LoadTesting +{ + /// A recommendation object that provides a list of configuration that optimizes its category. + public partial class TestProfileRunRecommendation + { + /// + /// 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 . + /// Category of the recommendation. + internal TestProfileRunRecommendation(RecommendationCategory category) + { + Category = category; + Configurations = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Category of the recommendation. + /// List of configurations IDs for which the recommendation is applicable. These are a subset of the provided target resource configurations. + /// Keeps track of any properties unknown to the library. + internal TestProfileRunRecommendation(RecommendationCategory category, IReadOnlyList configurations, IDictionary serializedAdditionalRawData) + { + Category = category; + Configurations = configurations; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TestProfileRunRecommendation() + { + } + + /// Category of the recommendation. + public RecommendationCategory Category { get; } + /// List of configurations IDs for which the recommendation is applicable. These are a subset of the provided target resource configurations. + public IReadOnlyList Configurations { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfileRunStatus.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfileRunStatus.cs new file mode 100644 index 000000000000..e7bd29c606fc --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestProfileRunStatus.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Test profile run status. + public readonly partial struct TestProfileRunStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TestProfileRunStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AcceptedValue = "ACCEPTED"; + private const string NotStartedValue = "NOTSTARTED"; + private const string ExecutingValue = "EXECUTING"; + private const string DoneValue = "DONE"; + private const string CancellingValue = "CANCELLING"; + private const string CancelledValue = "CANCELLED"; + private const string FailedValue = "FAILED"; + + /// Test profile run request is accepted. + public static TestProfileRunStatus Accepted { get; } = new TestProfileRunStatus(AcceptedValue); + /// Test profile run is not yet started. + public static TestProfileRunStatus NotStarted { get; } = new TestProfileRunStatus(NotStartedValue); + /// Test profile run has started executing. + public static TestProfileRunStatus Executing { get; } = new TestProfileRunStatus(ExecutingValue); + /// Test profile run has completed successfully. + public static TestProfileRunStatus Done { get; } = new TestProfileRunStatus(DoneValue); + /// Test profile run is being cancelled. + public static TestProfileRunStatus Cancelling { get; } = new TestProfileRunStatus(CancellingValue); + /// Test profile run is cancelled. + public static TestProfileRunStatus Cancelled { get; } = new TestProfileRunStatus(CancelledValue); + /// Test profile run has failed. + public static TestProfileRunStatus Failed { get; } = new TestProfileRunStatus(FailedValue); + /// Determines if two values are the same. + public static bool operator ==(TestProfileRunStatus left, TestProfileRunStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TestProfileRunStatus left, TestProfileRunStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator TestProfileRunStatus(string value) => new TestProfileRunStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TestProfileRunStatus other && Equals(other); + /// + public bool Equals(TestProfileRunStatus 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunAppComponents.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunAppComponents.Serialization.cs new file mode 100644 index 000000000000..448f8bcf972c --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunAppComponents.Serialization.cs @@ -0,0 +1,223 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class TestRunAppComponents : 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(TestRunAppComponents)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("components"u8); + writer.WriteStartObject(); + foreach (var item in Components) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + if (options.Format != "W" && Optional.IsDefined(TestRunId)) + { + writer.WritePropertyName("testRunId"u8); + writer.WriteStringValue(TestRunId); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedDateTime)) + { + writer.WritePropertyName("lastModifiedDateTime"u8); + writer.WriteStringValue(LastModifiedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedBy)) + { + writer.WritePropertyName("lastModifiedBy"u8); + writer.WriteStringValue(LastModifiedBy); + } + 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 + } + } + } + + TestRunAppComponents 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(TestRunAppComponents)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunAppComponents(document.RootElement, options); + } + + internal static TestRunAppComponents DeserializeTestRunAppComponents(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary components = default; + string testRunId = default; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("components"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, LoadTestingAppComponent.DeserializeLoadTestingAppComponent(property0.Value, options)); + } + components = dictionary; + continue; + } + if (property.NameEquals("testRunId"u8)) + { + testRunId = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRunAppComponents( + components, + testRunId, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + 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(TestRunAppComponents)} does not support writing '{options.Format}' format."); + } + } + + TestRunAppComponents 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 DeserializeTestRunAppComponents(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunAppComponents)} 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 TestRunAppComponents FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestRunAppComponents(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunAppComponents.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunAppComponents.cs new file mode 100644 index 000000000000..7df877f94aab --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunAppComponents.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Test run app component. + public partial class TestRunAppComponents + { + /// + /// 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 . + /// + /// Azure resource collection { resource id (fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + /// : resource object } + /// + /// is null. + public TestRunAppComponents(IDictionary components) + { + Argument.AssertNotNull(components, nameof(components)); + + Components = components; + } + + /// Initializes a new instance of . + /// + /// Azure resource collection { resource id (fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + /// : resource object } + /// + /// Test run identifier. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal TestRunAppComponents(IDictionary components, string testRunId, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + { + Components = components; + TestRunId = testRunId; + CreatedDateTime = createdDateTime; + CreatedBy = createdBy; + LastModifiedDateTime = lastModifiedDateTime; + LastModifiedBy = lastModifiedBy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TestRunAppComponents() + { + } + + /// + /// Azure resource collection { resource id (fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + /// : resource object } + /// + public IDictionary Components { get; } + /// Test run identifier. + public string TestRunId { get; } + /// The creation datetime(RFC 3339 literal format). + public DateTimeOffset? CreatedDateTime { get; } + /// The user that created. + public string CreatedBy { get; } + /// The last Modified datetime(RFC 3339 literal format). + public DateTimeOffset? LastModifiedDateTime { get; } + /// The user that last modified. + public string LastModifiedBy { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunArtifacts.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunArtifacts.Serialization.cs new file mode 100644 index 000000000000..1c5eac95657f --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunArtifacts.Serialization.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class TestRunArtifacts : 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(TestRunArtifacts)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(InputArtifacts)) + { + writer.WritePropertyName("inputArtifacts"u8); + writer.WriteObjectValue(InputArtifacts, options); + } + if (Optional.IsDefined(OutputArtifacts)) + { + writer.WritePropertyName("outputArtifacts"u8); + writer.WriteObjectValue(OutputArtifacts, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestRunArtifacts 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(TestRunArtifacts)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunArtifacts(document.RootElement, options); + } + + internal static TestRunArtifacts DeserializeTestRunArtifacts(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TestRunInputArtifacts inputArtifacts = default; + TestRunOutputArtifacts outputArtifacts = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("inputArtifacts"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + inputArtifacts = TestRunInputArtifacts.DeserializeTestRunInputArtifacts(property.Value, options); + continue; + } + if (property.NameEquals("outputArtifacts"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + outputArtifacts = TestRunOutputArtifacts.DeserializeTestRunOutputArtifacts(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRunArtifacts(inputArtifacts, outputArtifacts, 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(TestRunArtifacts)} does not support writing '{options.Format}' format."); + } + } + + TestRunArtifacts 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 DeserializeTestRunArtifacts(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunArtifacts)} 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 TestRunArtifacts FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestRunArtifacts(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunArtifacts.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunArtifacts.cs new file mode 100644 index 000000000000..ebf85cfa6567 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunArtifacts.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.Developer.LoadTesting +{ + /// Collection of test run artifacts. + public partial class TestRunArtifacts + { + /// + /// 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 TestRunArtifacts() + { + } + + /// Initializes a new instance of . + /// The input artifacts for the test run. + /// The output artifacts for the test run. + /// Keeps track of any properties unknown to the library. + internal TestRunArtifacts(TestRunInputArtifacts inputArtifacts, TestRunOutputArtifacts outputArtifacts, IDictionary serializedAdditionalRawData) + { + InputArtifacts = inputArtifacts; + OutputArtifacts = outputArtifacts; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The input artifacts for the test run. + public TestRunInputArtifacts InputArtifacts { get; } + /// The output artifacts for the test run. + public TestRunOutputArtifacts OutputArtifacts { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunDetail.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunDetail.Serialization.cs new file mode 100644 index 000000000000..b24aea0b6435 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunDetail.Serialization.cs @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class TestRunDetail : 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(TestRunDetail)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("configurationId"u8); + writer.WriteStringValue(ConfigurationId); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + foreach (var item in Properties) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestRunDetail 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(TestRunDetail)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunDetail(document.RootElement, options); + } + + internal static TestRunDetail DeserializeTestRunDetail(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TestRunStatus status = default; + string configurationId = default; + IReadOnlyDictionary properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("status"u8)) + { + status = new TestRunStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("configurationId"u8)) + { + configurationId = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + properties = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRunDetail(status, configurationId, properties, 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(TestRunDetail)} does not support writing '{options.Format}' format."); + } + } + + TestRunDetail 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 DeserializeTestRunDetail(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunDetail)} 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 TestRunDetail FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestRunDetail(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunDetail.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunDetail.cs new file mode 100644 index 000000000000..2be47512ac2b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunDetail.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Details of a particular test run for a test profile run. + public partial class TestRunDetail + { + /// + /// 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 . + /// Status of the test run. + /// ID of the configuration on which the test ran. + /// Key value pair of extra properties associated with the test run. + /// or is null. + internal TestRunDetail(TestRunStatus status, string configurationId, IReadOnlyDictionary properties) + { + Argument.AssertNotNull(configurationId, nameof(configurationId)); + Argument.AssertNotNull(properties, nameof(properties)); + + Status = status; + ConfigurationId = configurationId; + Properties = properties; + } + + /// Initializes a new instance of . + /// Status of the test run. + /// ID of the configuration on which the test ran. + /// Key value pair of extra properties associated with the test run. + /// Keeps track of any properties unknown to the library. + internal TestRunDetail(TestRunStatus status, string configurationId, IReadOnlyDictionary properties, IDictionary serializedAdditionalRawData) + { + Status = status; + ConfigurationId = configurationId; + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TestRunDetail() + { + } + + /// Status of the test run. + public TestRunStatus Status { get; } + /// ID of the configuration on which the test ran. + public string ConfigurationId { get; } + /// Key value pair of extra properties associated with the test run. + public IReadOnlyDictionary Properties { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunEndedEventCondition.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunEndedEventCondition.Serialization.cs new file mode 100644 index 000000000000..d69785f86608 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunEndedEventCondition.Serialization.cs @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class TestRunEndedEventCondition : 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(TestRunEndedEventCondition)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(TestRunStatuses)) + { + writer.WritePropertyName("testRunStatuses"u8); + writer.WriteStartArray(); + foreach (var item in TestRunStatuses) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(TestRunResults)) + { + writer.WritePropertyName("testRunResults"u8); + writer.WriteStartArray(); + foreach (var item in TestRunResults) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestRunEndedEventCondition 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(TestRunEndedEventCondition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunEndedEventCondition(document.RootElement, options); + } + + internal static TestRunEndedEventCondition DeserializeTestRunEndedEventCondition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList testRunStatuses = default; + IList testRunResults = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("testRunStatuses"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new TestRunStatus(item.GetString())); + } + testRunStatuses = array; + continue; + } + if (property.NameEquals("testRunResults"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new PassFailTestResult(item.GetString())); + } + testRunResults = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRunEndedEventCondition(testRunStatuses ?? new ChangeTrackingList(), testRunResults ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestRunEndedEventCondition)} does not support writing '{options.Format}' format."); + } + } + + TestRunEndedEventCondition 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 DeserializeTestRunEndedEventCondition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunEndedEventCondition)} 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 TestRunEndedEventCondition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestRunEndedEventCondition(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunEndedEventCondition.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunEndedEventCondition.cs new file mode 100644 index 000000000000..62f7e4e10c37 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunEndedEventCondition.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// TestRunEnded Event condition. + public partial class TestRunEndedEventCondition + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TestRunEndedEventCondition() + { + TestRunStatuses = new ChangeTrackingList(); + TestRunResults = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The test run statuses to send notification for. + /// The test run results to send notification for. + /// Keeps track of any properties unknown to the library. + internal TestRunEndedEventCondition(IList testRunStatuses, IList testRunResults, IDictionary serializedAdditionalRawData) + { + TestRunStatuses = testRunStatuses; + TestRunResults = testRunResults; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The test run statuses to send notification for. + public IList TestRunStatuses { get; } + /// The test run results to send notification for. + public IList TestRunResults { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunEndedNotificationEventFilter.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunEndedNotificationEventFilter.Serialization.cs new file mode 100644 index 000000000000..39e32e7e51f8 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunEndedNotificationEventFilter.Serialization.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class TestRunEndedNotificationEventFilter : 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(TestRunEndedNotificationEventFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Condition)) + { + writer.WritePropertyName("condition"u8); + writer.WriteObjectValue(Condition, options); + } + } + + TestRunEndedNotificationEventFilter 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(TestRunEndedNotificationEventFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunEndedNotificationEventFilter(document.RootElement, options); + } + + internal static TestRunEndedNotificationEventFilter DeserializeTestRunEndedNotificationEventFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TestRunEndedEventCondition condition = default; + NotificationEventType kind = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("condition"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + condition = TestRunEndedEventCondition.DeserializeTestRunEndedEventCondition(property.Value, options); + continue; + } + if (property.NameEquals("kind"u8)) + { + kind = new NotificationEventType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRunEndedNotificationEventFilter(kind, serializedAdditionalRawData, condition); + } + + 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(TestRunEndedNotificationEventFilter)} does not support writing '{options.Format}' format."); + } + } + + TestRunEndedNotificationEventFilter 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 DeserializeTestRunEndedNotificationEventFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunEndedNotificationEventFilter)} 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 TestRunEndedNotificationEventFilter FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestRunEndedNotificationEventFilter(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunEndedNotificationEventFilter.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunEndedNotificationEventFilter.cs new file mode 100644 index 000000000000..e3d4eeb87020 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunEndedNotificationEventFilter.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// The notification event filter when the event type is TestRunEnded and scope is Tests. + public partial class TestRunEndedNotificationEventFilter : TestsNotificationEventFilter + { + /// Initializes a new instance of . + public TestRunEndedNotificationEventFilter() + { + Kind = NotificationEventType.TestRunEnded; + } + + /// Initializes a new instance of . + /// The event type. + /// Keeps track of any properties unknown to the library. + /// Event filtering condition. + internal TestRunEndedNotificationEventFilter(NotificationEventType kind, IDictionary serializedAdditionalRawData, TestRunEndedEventCondition condition) : base(kind, serializedAdditionalRawData) + { + Condition = condition; + } + + /// Event filtering condition. + public TestRunEndedEventCondition Condition { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunFileInfo.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunFileInfo.Serialization.cs new file mode 100644 index 000000000000..78bef4881be4 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunFileInfo.Serialization.cs @@ -0,0 +1,220 @@ +// 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.Developer.LoadTesting +{ + public partial class TestRunFileInfo : 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(TestRunFileInfo)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("fileName"u8); + writer.WriteStringValue(FileName); + if (options.Format != "W" && Optional.IsDefined(Uri)) + { + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Uri.AbsoluteUri); + } + if (options.Format != "W" && Optional.IsDefined(FileType)) + { + writer.WritePropertyName("fileType"u8); + writer.WriteStringValue(FileType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ExpiresOn)) + { + writer.WritePropertyName("expireDateTime"u8); + writer.WriteStringValue(ExpiresOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ValidationStatus)) + { + writer.WritePropertyName("validationStatus"u8); + writer.WriteStringValue(ValidationStatus.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ValidationFailureDetails)) + { + writer.WritePropertyName("validationFailureDetails"u8); + writer.WriteStringValue(ValidationFailureDetails); + } + 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 + } + } + } + + TestRunFileInfo 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(TestRunFileInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunFileInfo(document.RootElement, options); + } + + internal static TestRunFileInfo DeserializeTestRunFileInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileName = default; + Uri url = default; + LoadTestingFileType? fileType = default; + DateTimeOffset? expireDateTime = default; + FileValidationStatus? validationStatus = default; + string validationFailureDetails = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("fileName"u8)) + { + fileName = property.Value.GetString(); + continue; + } + if (property.NameEquals("url"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + url = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("fileType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fileType = new LoadTestingFileType(property.Value.GetString()); + continue; + } + if (property.NameEquals("expireDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expireDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("validationStatus"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + validationStatus = new FileValidationStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("validationFailureDetails"u8)) + { + validationFailureDetails = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRunFileInfo( + fileName, + url, + fileType, + expireDateTime, + validationStatus, + validationFailureDetails, + 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(TestRunFileInfo)} does not support writing '{options.Format}' format."); + } + } + + TestRunFileInfo 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 DeserializeTestRunFileInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunFileInfo)} 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 TestRunFileInfo FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestRunFileInfo(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunFileInfo.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunFileInfo.cs new file mode 100644 index 000000000000..57896a725b79 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunFileInfo.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Test run file info. + public partial class TestRunFileInfo + { + /// + /// 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 . + /// Name of the file. + /// is null. + internal TestRunFileInfo(string fileName) + { + Argument.AssertNotNull(fileName, nameof(fileName)); + + FileName = fileName; + } + + /// Initializes a new instance of . + /// Name of the file. + /// File URL. + /// File type. + /// Expiry time of the file (RFC 3339 literal format). + /// Validation status of the file. + /// Validation failure error details. + /// Keeps track of any properties unknown to the library. + internal TestRunFileInfo(string fileName, Uri uri, LoadTestingFileType? fileType, DateTimeOffset? expiresOn, FileValidationStatus? validationStatus, string validationFailureDetails, IDictionary serializedAdditionalRawData) + { + FileName = fileName; + Uri = uri; + FileType = fileType; + ExpiresOn = expiresOn; + ValidationStatus = validationStatus; + ValidationFailureDetails = validationFailureDetails; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TestRunFileInfo() + { + } + + /// Name of the file. + public string FileName { get; } + /// File URL. + public Uri Uri { get; } + /// File type. + public LoadTestingFileType? FileType { get; } + /// Expiry time of the file (RFC 3339 literal format). + public DateTimeOffset? ExpiresOn { get; } + /// Validation status of the file. + public FileValidationStatus? ValidationStatus { get; } + /// Validation failure error details. + public string ValidationFailureDetails { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunInputArtifacts.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunInputArtifacts.Serialization.cs new file mode 100644 index 000000000000..352fc13cf84f --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunInputArtifacts.Serialization.cs @@ -0,0 +1,241 @@ +// 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.Developer.LoadTesting +{ + public partial class TestRunInputArtifacts : 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(TestRunInputArtifacts)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ConfigFileInfo)) + { + writer.WritePropertyName("configFileInfo"u8); + writer.WriteObjectValue(ConfigFileInfo, options); + } + if (Optional.IsDefined(TestScriptFileInfo)) + { + writer.WritePropertyName("testScriptFileInfo"u8); + writer.WriteObjectValue(TestScriptFileInfo, options); + } + if (Optional.IsDefined(UserPropertyFileInfo)) + { + writer.WritePropertyName("userPropFileInfo"u8); + writer.WriteObjectValue(UserPropertyFileInfo, options); + } + if (Optional.IsDefined(InputArtifactsZipFileInfo)) + { + writer.WritePropertyName("inputArtifactsZipFileInfo"u8); + writer.WriteObjectValue(InputArtifactsZipFileInfo, options); + } + if (Optional.IsDefined(UrlTestConfigFileInfo)) + { + writer.WritePropertyName("urlTestConfigFileInfo"u8); + writer.WriteObjectValue(UrlTestConfigFileInfo, options); + } + if (options.Format != "W" && Optional.IsCollectionDefined(AdditionalFileInfo)) + { + writer.WritePropertyName("additionalFileInfo"u8); + writer.WriteStartArray(); + foreach (var item in AdditionalFileInfo) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestRunInputArtifacts 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(TestRunInputArtifacts)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunInputArtifacts(document.RootElement, options); + } + + internal static TestRunInputArtifacts DeserializeTestRunInputArtifacts(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TestRunFileInfo configFileInfo = default; + TestRunFileInfo testScriptFileInfo = default; + TestRunFileInfo userPropFileInfo = default; + TestRunFileInfo inputArtifactsZipFileInfo = default; + TestRunFileInfo urlTestConfigFileInfo = default; + IReadOnlyList additionalFileInfo = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("configFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + configFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("testScriptFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + testScriptFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("userPropFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + userPropFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("inputArtifactsZipFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + inputArtifactsZipFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("urlTestConfigFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + urlTestConfigFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("additionalFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TestRunFileInfo.DeserializeTestRunFileInfo(item, options)); + } + additionalFileInfo = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRunInputArtifacts( + configFileInfo, + testScriptFileInfo, + userPropFileInfo, + inputArtifactsZipFileInfo, + urlTestConfigFileInfo, + additionalFileInfo ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestRunInputArtifacts)} does not support writing '{options.Format}' format."); + } + } + + TestRunInputArtifacts 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 DeserializeTestRunInputArtifacts(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunInputArtifacts)} 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 TestRunInputArtifacts FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestRunInputArtifacts(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunInputArtifacts.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunInputArtifacts.cs new file mode 100644 index 000000000000..bc2161dfff03 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunInputArtifacts.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.Developer.LoadTesting +{ + /// The input artifacts for the test run. + public partial class TestRunInputArtifacts + { + /// + /// 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 TestRunInputArtifacts() + { + AdditionalFileInfo = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The load test YAML file that contains the the test configuration. + /// The test script file for the test run. + /// The user properties file. + /// The zip file for all input artifacts. + /// The config json file for url based test. + /// Additional supported files for the test run. + /// Keeps track of any properties unknown to the library. + internal TestRunInputArtifacts(TestRunFileInfo configFileInfo, TestRunFileInfo testScriptFileInfo, TestRunFileInfo userPropertyFileInfo, TestRunFileInfo inputArtifactsZipFileInfo, TestRunFileInfo urlTestConfigFileInfo, IReadOnlyList additionalFileInfo, IDictionary serializedAdditionalRawData) + { + ConfigFileInfo = configFileInfo; + TestScriptFileInfo = testScriptFileInfo; + UserPropertyFileInfo = userPropertyFileInfo; + InputArtifactsZipFileInfo = inputArtifactsZipFileInfo; + UrlTestConfigFileInfo = urlTestConfigFileInfo; + AdditionalFileInfo = additionalFileInfo; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The load test YAML file that contains the the test configuration. + public TestRunFileInfo ConfigFileInfo { get; } + /// The test script file for the test run. + public TestRunFileInfo TestScriptFileInfo { get; } + /// The user properties file. + public TestRunFileInfo UserPropertyFileInfo { get; } + /// The zip file for all input artifacts. + public TestRunFileInfo InputArtifactsZipFileInfo { get; } + /// The config json file for url based test. + public TestRunFileInfo UrlTestConfigFileInfo { get; } + /// Additional supported files for the test run. + public IReadOnlyList AdditionalFileInfo { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunOutputArtifacts.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunOutputArtifacts.Serialization.cs new file mode 100644 index 000000000000..aabcb0665129 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunOutputArtifacts.Serialization.cs @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class TestRunOutputArtifacts : 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(TestRunOutputArtifacts)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ResultFileInfo)) + { + writer.WritePropertyName("resultFileInfo"u8); + writer.WriteObjectValue(ResultFileInfo, options); + } + if (Optional.IsDefined(LogsFileInfo)) + { + writer.WritePropertyName("logsFileInfo"u8); + writer.WriteObjectValue(LogsFileInfo, options); + } + if (Optional.IsDefined(ArtifactsContainerInfo)) + { + writer.WritePropertyName("artifactsContainerInfo"u8); + writer.WriteObjectValue(ArtifactsContainerInfo, options); + } + if (Optional.IsDefined(ReportFileInfo)) + { + writer.WritePropertyName("reportFileInfo"u8); + writer.WriteObjectValue(ReportFileInfo, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestRunOutputArtifacts 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(TestRunOutputArtifacts)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunOutputArtifacts(document.RootElement, options); + } + + internal static TestRunOutputArtifacts DeserializeTestRunOutputArtifacts(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TestRunFileInfo resultFileInfo = default; + TestRunFileInfo logsFileInfo = default; + ArtifactsContainerInfo artifactsContainerInfo = default; + TestRunFileInfo reportFileInfo = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resultFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resultFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("logsFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + logsFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("artifactsContainerInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + artifactsContainerInfo = ArtifactsContainerInfo.DeserializeArtifactsContainerInfo(property.Value, options); + continue; + } + if (property.NameEquals("reportFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + reportFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRunOutputArtifacts(resultFileInfo, logsFileInfo, artifactsContainerInfo, reportFileInfo, 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(TestRunOutputArtifacts)} does not support writing '{options.Format}' format."); + } + } + + TestRunOutputArtifacts 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 DeserializeTestRunOutputArtifacts(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunOutputArtifacts)} 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 TestRunOutputArtifacts FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestRunOutputArtifacts(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunOutputArtifacts.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunOutputArtifacts.cs new file mode 100644 index 000000000000..2d16a4940219 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunOutputArtifacts.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.Developer.LoadTesting +{ + /// The output artifacts for the test run. + public partial class TestRunOutputArtifacts + { + /// + /// 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 TestRunOutputArtifacts() + { + } + + /// Initializes a new instance of . + /// The test run results file. + /// The test run report with metrics. + /// The container for test run artifacts. + /// The report file for the test run. + /// Keeps track of any properties unknown to the library. + internal TestRunOutputArtifacts(TestRunFileInfo resultFileInfo, TestRunFileInfo logsFileInfo, ArtifactsContainerInfo artifactsContainerInfo, TestRunFileInfo reportFileInfo, IDictionary serializedAdditionalRawData) + { + ResultFileInfo = resultFileInfo; + LogsFileInfo = logsFileInfo; + ArtifactsContainerInfo = artifactsContainerInfo; + ReportFileInfo = reportFileInfo; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The test run results file. + public TestRunFileInfo ResultFileInfo { get; } + /// The test run report with metrics. + public TestRunFileInfo LogsFileInfo { get; } + /// The container for test run artifacts. + public ArtifactsContainerInfo ArtifactsContainerInfo { get; } + /// The report file for the test run. + public TestRunFileInfo ReportFileInfo { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunServerMetricsConfiguration.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunServerMetricsConfiguration.Serialization.cs new file mode 100644 index 000000000000..b25816407cba --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunServerMetricsConfiguration.Serialization.cs @@ -0,0 +1,230 @@ +// 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.Developer.LoadTesting +{ + public partial class TestRunServerMetricsConfiguration : 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(TestRunServerMetricsConfiguration)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(TestRunId)) + { + writer.WritePropertyName("testRunId"u8); + writer.WriteStringValue(TestRunId); + } + if (Optional.IsCollectionDefined(Metrics)) + { + writer.WritePropertyName("metrics"u8); + writer.WriteStartObject(); + foreach (var item in Metrics) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedDateTime)) + { + writer.WritePropertyName("lastModifiedDateTime"u8); + writer.WriteStringValue(LastModifiedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedBy)) + { + writer.WritePropertyName("lastModifiedBy"u8); + writer.WriteStringValue(LastModifiedBy); + } + 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 + } + } + } + + TestRunServerMetricsConfiguration 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(TestRunServerMetricsConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunServerMetricsConfiguration(document.RootElement, options); + } + + internal static TestRunServerMetricsConfiguration DeserializeTestRunServerMetricsConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string testRunId = default; + IDictionary metrics = default; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("testRunId"u8)) + { + testRunId = property.Value.GetString(); + continue; + } + if (property.NameEquals("metrics"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, ResourceMetric.DeserializeResourceMetric(property0.Value, options)); + } + metrics = dictionary; + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRunServerMetricsConfiguration( + testRunId, + metrics ?? new ChangeTrackingDictionary(), + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + 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(TestRunServerMetricsConfiguration)} does not support writing '{options.Format}' format."); + } + } + + TestRunServerMetricsConfiguration 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 DeserializeTestRunServerMetricsConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunServerMetricsConfiguration)} 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 TestRunServerMetricsConfiguration FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestRunServerMetricsConfiguration(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunServerMetricsConfiguration.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunServerMetricsConfiguration.cs new file mode 100644 index 000000000000..b9a6d3ef0c4a --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunServerMetricsConfiguration.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Test run server metrics configuration. + public partial class TestRunServerMetricsConfiguration + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TestRunServerMetricsConfiguration() + { + Metrics = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Test run identifier. + /// + /// Azure resource metrics collection {metric id : metrics object} (Refer : + /// https://learn.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition + /// for metric id). + /// + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal TestRunServerMetricsConfiguration(string testRunId, IDictionary metrics, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + { + TestRunId = testRunId; + Metrics = metrics; + CreatedDateTime = createdDateTime; + CreatedBy = createdBy; + LastModifiedDateTime = lastModifiedDateTime; + LastModifiedBy = lastModifiedBy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Test run identifier. + public string TestRunId { get; } + /// + /// Azure resource metrics collection {metric id : metrics object} (Refer : + /// https://learn.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition + /// for metric id). + /// + public IDictionary Metrics { get; } + /// The creation datetime(RFC 3339 literal format). + public DateTimeOffset? CreatedDateTime { get; } + /// The user that created. + public string CreatedBy { get; } + /// The last Modified datetime(RFC 3339 literal format). + public DateTimeOffset? LastModifiedDateTime { get; } + /// The user that last modified. + public string LastModifiedBy { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunStartedNotificationEventFilter.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunStartedNotificationEventFilter.Serialization.cs new file mode 100644 index 000000000000..78200f13c469 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunStartedNotificationEventFilter.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class TestRunStartedNotificationEventFilter : 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(TestRunStartedNotificationEventFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + TestRunStartedNotificationEventFilter 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(TestRunStartedNotificationEventFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunStartedNotificationEventFilter(document.RootElement, options); + } + + internal static TestRunStartedNotificationEventFilter DeserializeTestRunStartedNotificationEventFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + NotificationEventType kind = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("kind"u8)) + { + kind = new NotificationEventType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRunStartedNotificationEventFilter(kind, 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(TestRunStartedNotificationEventFilter)} does not support writing '{options.Format}' format."); + } + } + + TestRunStartedNotificationEventFilter 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 DeserializeTestRunStartedNotificationEventFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunStartedNotificationEventFilter)} 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 TestRunStartedNotificationEventFilter FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestRunStartedNotificationEventFilter(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunStartedNotificationEventFilter.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunStartedNotificationEventFilter.cs new file mode 100644 index 000000000000..c8e30641e3e7 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunStartedNotificationEventFilter.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// The notification event filter when the event type is TestRunStarted and scope is Tests. + public partial class TestRunStartedNotificationEventFilter : TestsNotificationEventFilter + { + /// Initializes a new instance of . + public TestRunStartedNotificationEventFilter() + { + Kind = NotificationEventType.TestRunStarted; + } + + /// Initializes a new instance of . + /// The event type. + /// Keeps track of any properties unknown to the library. + internal TestRunStartedNotificationEventFilter(NotificationEventType kind, IDictionary serializedAdditionalRawData) : base(kind, serializedAdditionalRawData) + { + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunStatistics.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunStatistics.Serialization.cs new file mode 100644 index 000000000000..17e04f586300 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunStatistics.Serialization.cs @@ -0,0 +1,451 @@ +// 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.Developer.LoadTesting +{ + public partial class TestRunStatistics : 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(TestRunStatistics)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Transaction)) + { + writer.WritePropertyName("transaction"u8); + writer.WriteStringValue(Transaction); + } + if (options.Format != "W" && Optional.IsDefined(SampleCount)) + { + writer.WritePropertyName("sampleCount"u8); + writer.WriteNumberValue(SampleCount.Value); + } + if (options.Format != "W" && Optional.IsDefined(ErrorCount)) + { + writer.WritePropertyName("errorCount"u8); + writer.WriteNumberValue(ErrorCount.Value); + } + if (options.Format != "W" && Optional.IsDefined(ErrorPercentage)) + { + writer.WritePropertyName("errorPct"u8); + writer.WriteNumberValue(ErrorPercentage.Value); + } + if (options.Format != "W" && Optional.IsDefined(MeanResponseTime)) + { + writer.WritePropertyName("meanResTime"u8); + writer.WriteNumberValue(MeanResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(MedianResponseTime)) + { + writer.WritePropertyName("medianResTime"u8); + writer.WriteNumberValue(MedianResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(MaxResponseTime)) + { + writer.WritePropertyName("maxResTime"u8); + writer.WriteNumberValue(MaxResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(MinResponseTime)) + { + writer.WritePropertyName("minResTime"u8); + writer.WriteNumberValue(MinResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Percentile90ResponseTime)) + { + writer.WritePropertyName("pct1ResTime"u8); + writer.WriteNumberValue(Percentile90ResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Percentile95ResponseTime)) + { + writer.WritePropertyName("pct2ResTime"u8); + writer.WriteNumberValue(Percentile95ResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Percentile99ResponseTime)) + { + writer.WritePropertyName("pct3ResTime"u8); + writer.WriteNumberValue(Percentile99ResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Percentile75ResponseTime)) + { + writer.WritePropertyName("pct75ResTime"u8); + writer.WriteNumberValue(Percentile75ResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Percentile96ResponseTime)) + { + writer.WritePropertyName("pct96ResTime"u8); + writer.WriteNumberValue(Percentile96ResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Percentile97ResponseTime)) + { + writer.WritePropertyName("pct97ResTime"u8); + writer.WriteNumberValue(Percentile97ResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Percentile98ResponseTime)) + { + writer.WritePropertyName("pct98ResTime"u8); + writer.WriteNumberValue(Percentile98ResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Percentile999ResponseTime)) + { + writer.WritePropertyName("pct999ResTime"u8); + writer.WriteNumberValue(Percentile999ResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Percentile9999ResponseTime)) + { + writer.WritePropertyName("pct9999ResTime"u8); + writer.WriteNumberValue(Percentile9999ResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Throughput)) + { + writer.WritePropertyName("throughput"u8); + writer.WriteNumberValue(Throughput.Value); + } + if (options.Format != "W" && Optional.IsDefined(ReceivedKBytesPerSec)) + { + writer.WritePropertyName("receivedKBytesPerSec"u8); + writer.WriteNumberValue(ReceivedKBytesPerSec.Value); + } + if (options.Format != "W" && Optional.IsDefined(SentKBytesPerSec)) + { + writer.WritePropertyName("sentKBytesPerSec"u8); + writer.WriteNumberValue(SentKBytesPerSec.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestRunStatistics 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(TestRunStatistics)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunStatistics(document.RootElement, options); + } + + internal static TestRunStatistics DeserializeTestRunStatistics(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string transaction = default; + double? sampleCount = default; + double? errorCount = default; + double? errorPct = default; + double? meanResTime = default; + double? medianResTime = default; + double? maxResTime = default; + double? minResTime = default; + double? pct1ResTime = default; + double? pct2ResTime = default; + double? pct3ResTime = default; + double? pct75ResTime = default; + double? pct96ResTime = default; + double? pct97ResTime = default; + double? pct98ResTime = default; + double? pct999ResTime = default; + double? pct9999ResTime = default; + double? throughput = default; + double? receivedKBytesPerSec = default; + double? sentKBytesPerSec = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("transaction"u8)) + { + transaction = property.Value.GetString(); + continue; + } + if (property.NameEquals("sampleCount"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sampleCount = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("errorCount"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + errorCount = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("errorPct"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + errorPct = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("meanResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + meanResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("medianResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + medianResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("maxResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("minResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + minResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("pct1ResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pct1ResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("pct2ResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pct2ResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("pct3ResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pct3ResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("pct75ResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pct75ResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("pct96ResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pct96ResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("pct97ResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pct97ResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("pct98ResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pct98ResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("pct999ResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pct999ResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("pct9999ResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pct9999ResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("throughput"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + throughput = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("receivedKBytesPerSec"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + receivedKBytesPerSec = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("sentKBytesPerSec"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sentKBytesPerSec = property.Value.GetDouble(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRunStatistics( + transaction, + sampleCount, + errorCount, + errorPct, + meanResTime, + medianResTime, + maxResTime, + minResTime, + pct1ResTime, + pct2ResTime, + pct3ResTime, + pct75ResTime, + pct96ResTime, + pct97ResTime, + pct98ResTime, + pct999ResTime, + pct9999ResTime, + throughput, + receivedKBytesPerSec, + sentKBytesPerSec, + 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(TestRunStatistics)} does not support writing '{options.Format}' format."); + } + } + + TestRunStatistics 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 DeserializeTestRunStatistics(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunStatistics)} 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 TestRunStatistics FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestRunStatistics(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunStatistics.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunStatistics.cs new file mode 100644 index 000000000000..314487a581c8 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunStatistics.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Test run statistics. + public partial class TestRunStatistics + { + /// + /// 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 TestRunStatistics() + { + } + + /// Initializes a new instance of . + /// Transaction name. + /// Sampler count. + /// Error count. + /// Error percentage. + /// Mean response time. + /// Median response time. + /// Max response time. + /// Minimum response time. + /// 90 percentile response time. + /// 95 percentile response time. + /// 99 percentile response time. + /// 75 percentile response time. + /// 96 percentile response time. + /// 97 percentile response time. + /// 98 percentile response time. + /// 99.9 percentile response time. + /// 99.99 percentile response time. + /// Throughput. + /// Received network bytes. + /// Send network bytes. + /// Keeps track of any properties unknown to the library. + internal TestRunStatistics(string transaction, double? sampleCount, double? errorCount, double? errorPercentage, double? meanResponseTime, double? medianResponseTime, double? maxResponseTime, double? minResponseTime, double? percentile90ResponseTime, double? percentile95ResponseTime, double? percentile99ResponseTime, double? percentile75ResponseTime, double? percentile96ResponseTime, double? percentile97ResponseTime, double? percentile98ResponseTime, double? percentile999ResponseTime, double? percentile9999ResponseTime, double? throughput, double? receivedKBytesPerSec, double? sentKBytesPerSec, IDictionary serializedAdditionalRawData) + { + Transaction = transaction; + SampleCount = sampleCount; + ErrorCount = errorCount; + ErrorPercentage = errorPercentage; + MeanResponseTime = meanResponseTime; + MedianResponseTime = medianResponseTime; + MaxResponseTime = maxResponseTime; + MinResponseTime = minResponseTime; + Percentile90ResponseTime = percentile90ResponseTime; + Percentile95ResponseTime = percentile95ResponseTime; + Percentile99ResponseTime = percentile99ResponseTime; + Percentile75ResponseTime = percentile75ResponseTime; + Percentile96ResponseTime = percentile96ResponseTime; + Percentile97ResponseTime = percentile97ResponseTime; + Percentile98ResponseTime = percentile98ResponseTime; + Percentile999ResponseTime = percentile999ResponseTime; + Percentile9999ResponseTime = percentile9999ResponseTime; + Throughput = throughput; + ReceivedKBytesPerSec = receivedKBytesPerSec; + SentKBytesPerSec = sentKBytesPerSec; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Transaction name. + public string Transaction { get; } + /// Sampler count. + public double? SampleCount { get; } + /// Error count. + public double? ErrorCount { get; } + /// Error percentage. + public double? ErrorPercentage { get; } + /// Mean response time. + public double? MeanResponseTime { get; } + /// Median response time. + public double? MedianResponseTime { get; } + /// Max response time. + public double? MaxResponseTime { get; } + /// Minimum response time. + public double? MinResponseTime { get; } + /// 90 percentile response time. + public double? Percentile90ResponseTime { get; } + /// 95 percentile response time. + public double? Percentile95ResponseTime { get; } + /// 99 percentile response time. + public double? Percentile99ResponseTime { get; } + /// 75 percentile response time. + public double? Percentile75ResponseTime { get; } + /// 96 percentile response time. + public double? Percentile96ResponseTime { get; } + /// 97 percentile response time. + public double? Percentile97ResponseTime { get; } + /// 98 percentile response time. + public double? Percentile98ResponseTime { get; } + /// 99.9 percentile response time. + public double? Percentile999ResponseTime { get; } + /// 99.99 percentile response time. + public double? Percentile9999ResponseTime { get; } + /// Throughput. + public double? Throughput { get; } + /// Received network bytes. + public double? ReceivedKBytesPerSec { get; } + /// Send network bytes. + public double? SentKBytesPerSec { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunStatus.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunStatus.cs new file mode 100644 index 000000000000..53ee327572e5 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestRunStatus.cs @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Test run status. + public readonly partial struct TestRunStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TestRunStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AcceptedValue = "ACCEPTED"; + private const string NotStartedValue = "NOTSTARTED"; + private const string ProvisioningValue = "PROVISIONING"; + private const string ProvisionedValue = "PROVISIONED"; + private const string ConfiguringValue = "CONFIGURING"; + private const string ConfiguredValue = "CONFIGURED"; + private const string ExecutingValue = "EXECUTING"; + private const string ExecutedValue = "EXECUTED"; + private const string DeprovisioningValue = "DEPROVISIONING"; + private const string DeprovisionedValue = "DEPROVISIONED"; + private const string DoneValue = "DONE"; + private const string CancellingValue = "CANCELLING"; + private const string CancelledValue = "CANCELLED"; + private const string FailedValue = "FAILED"; + private const string ValidationSuccessValue = "VALIDATION_SUCCESS"; + private const string ValidationFailureValue = "VALIDATION_FAILURE"; + + /// Test run request is accepted. + public static TestRunStatus Accepted { get; } = new TestRunStatus(AcceptedValue); + /// Test run is not yet started. + public static TestRunStatus NotStarted { get; } = new TestRunStatus(NotStartedValue); + /// Test run is provisioning. + public static TestRunStatus Provisioning { get; } = new TestRunStatus(ProvisioningValue); + /// Test run is provisioned. + public static TestRunStatus Provisioned { get; } = new TestRunStatus(ProvisionedValue); + /// Test run is getting configured. + public static TestRunStatus Configuring { get; } = new TestRunStatus(ConfiguringValue); + /// Test run configuration is done. + public static TestRunStatus Configured { get; } = new TestRunStatus(ConfiguredValue); + /// Test run has started executing. + public static TestRunStatus Executing { get; } = new TestRunStatus(ExecutingValue); + /// Test run execution is completed. + public static TestRunStatus Executed { get; } = new TestRunStatus(ExecutedValue); + /// Test run is getting deprovisioned. + public static TestRunStatus Deprovisioning { get; } = new TestRunStatus(DeprovisioningValue); + /// Test run is deprovisioned. + public static TestRunStatus Deprovisioned { get; } = new TestRunStatus(DeprovisionedValue); + /// Test run is completed. + public static TestRunStatus Done { get; } = new TestRunStatus(DoneValue); + /// Test run is being cancelled. + public static TestRunStatus Cancelling { get; } = new TestRunStatus(CancellingValue); + /// Test run request is cancelled. + public static TestRunStatus Cancelled { get; } = new TestRunStatus(CancelledValue); + /// Test run request is failed. + public static TestRunStatus Failed { get; } = new TestRunStatus(FailedValue); + /// Test run JMX file is validated. + public static TestRunStatus ValidationSuccess { get; } = new TestRunStatus(ValidationSuccessValue); + /// Test run JMX file validation is failed. + public static TestRunStatus ValidationFailure { get; } = new TestRunStatus(ValidationFailureValue); + /// Determines if two values are the same. + public static bool operator ==(TestRunStatus left, TestRunStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TestRunStatus left, TestRunStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator TestRunStatus(string value) => new TestRunStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TestRunStatus other && Equals(other); + /// + public bool Equals(TestRunStatus 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestSecret.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestSecret.Serialization.cs new file mode 100644 index 000000000000..b83bf416e9fa --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestSecret.Serialization.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class TestSecret : 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(TestSecret)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + } + if (Optional.IsDefined(SecretKind)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(SecretKind.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestSecret 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(TestSecret)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestSecret(document.RootElement, options); + } + + internal static TestSecret DeserializeTestSecret(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string value = default; + SecretType? type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + value = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + type = new SecretType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestSecret(value, type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestSecret)} does not support writing '{options.Format}' format."); + } + } + + TestSecret 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 DeserializeTestSecret(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestSecret)} 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 TestSecret FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestSecret(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestSecret.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestSecret.cs new file mode 100644 index 000000000000..8e3fdb7897ae --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestSecret.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.Developer.LoadTesting +{ + /// Secret. + public partial class TestSecret + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TestSecret() + { + } + + /// Initializes a new instance of . + /// The value of the secret for the respective type. + /// Type of secret. + /// Keeps track of any properties unknown to the library. + internal TestSecret(string value, SecretType? secretKind, IDictionary serializedAdditionalRawData) + { + Value = value; + SecretKind = secretKind; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The value of the secret for the respective type. + public string Value { get; set; } + /// Type of secret. + public SecretType? SecretKind { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestServerMetricsConfiguration.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestServerMetricsConfiguration.Serialization.cs new file mode 100644 index 000000000000..696e0350998b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestServerMetricsConfiguration.Serialization.cs @@ -0,0 +1,223 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class TestServerMetricsConfiguration : 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(TestServerMetricsConfiguration)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(TestId)) + { + writer.WritePropertyName("testId"u8); + writer.WriteStringValue(TestId); + } + writer.WritePropertyName("metrics"u8); + writer.WriteStartObject(); + foreach (var item in Metrics) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedDateTime)) + { + writer.WritePropertyName("lastModifiedDateTime"u8); + writer.WriteStringValue(LastModifiedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedBy)) + { + writer.WritePropertyName("lastModifiedBy"u8); + writer.WriteStringValue(LastModifiedBy); + } + 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 + } + } + } + + TestServerMetricsConfiguration 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(TestServerMetricsConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestServerMetricsConfiguration(document.RootElement, options); + } + + internal static TestServerMetricsConfiguration DeserializeTestServerMetricsConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string testId = default; + IDictionary metrics = default; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("testId"u8)) + { + testId = property.Value.GetString(); + continue; + } + if (property.NameEquals("metrics"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, ResourceMetric.DeserializeResourceMetric(property0.Value, options)); + } + metrics = dictionary; + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestServerMetricsConfiguration( + testId, + metrics, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + 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(TestServerMetricsConfiguration)} does not support writing '{options.Format}' format."); + } + } + + TestServerMetricsConfiguration 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 DeserializeTestServerMetricsConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestServerMetricsConfiguration)} 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 TestServerMetricsConfiguration FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestServerMetricsConfiguration(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestServerMetricsConfiguration.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestServerMetricsConfiguration.cs new file mode 100644 index 000000000000..c36ad8b4f554 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestServerMetricsConfiguration.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Test server metrics configuration. + public partial class TestServerMetricsConfiguration + { + /// + /// 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 . + /// + /// Azure resource metrics collection {metric id : metrics object} (Refer : + /// https://learn.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition + /// for metric id). + /// + /// is null. + public TestServerMetricsConfiguration(IDictionary metrics) + { + Argument.AssertNotNull(metrics, nameof(metrics)); + + Metrics = metrics; + } + + /// Initializes a new instance of . + /// Test identifier. + /// + /// Azure resource metrics collection {metric id : metrics object} (Refer : + /// https://learn.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition + /// for metric id). + /// + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal TestServerMetricsConfiguration(string testId, IDictionary metrics, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + { + TestId = testId; + Metrics = metrics; + CreatedDateTime = createdDateTime; + CreatedBy = createdBy; + LastModifiedDateTime = lastModifiedDateTime; + LastModifiedBy = lastModifiedBy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TestServerMetricsConfiguration() + { + } + + /// Test identifier. + public string TestId { get; } + /// + /// Azure resource metrics collection {metric id : metrics object} (Refer : + /// https://learn.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition + /// for metric id). + /// + public IDictionary Metrics { get; } + /// The creation datetime(RFC 3339 literal format). + public DateTimeOffset? CreatedDateTime { get; } + /// The user that created. + public string CreatedBy { get; } + /// The last Modified datetime(RFC 3339 literal format). + public DateTimeOffset? LastModifiedDateTime { get; } + /// The user that last modified. + public string LastModifiedBy { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestsNotificationEventFilter.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestsNotificationEventFilter.Serialization.cs new file mode 100644 index 000000000000..83f6e5b0fd5e --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestsNotificationEventFilter.Serialization.cs @@ -0,0 +1,136 @@ +// 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.Developer.LoadTesting +{ + [PersistableModelProxy(typeof(UnknownTestsNotificationEventFilter))] + public partial class TestsNotificationEventFilter : 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(TestsNotificationEventFilter)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.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 + } + } + } + + TestsNotificationEventFilter 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(TestsNotificationEventFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestsNotificationEventFilter(document.RootElement, options); + } + + internal static TestsNotificationEventFilter DeserializeTestsNotificationEventFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("kind", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "TestRunEnded": return TestRunEndedNotificationEventFilter.DeserializeTestRunEndedNotificationEventFilter(element, options); + case "TestRunStarted": return TestRunStartedNotificationEventFilter.DeserializeTestRunStartedNotificationEventFilter(element, options); + case "TriggerCompleted": return TriggerCompletedNotificationEventFilter.DeserializeTriggerCompletedNotificationEventFilter(element, options); + case "TriggerDisabled": return TriggerDisabledNotificationEventFilter.DeserializeTriggerDisabledNotificationEventFilter(element, options); + } + } + return UnknownTestsNotificationEventFilter.DeserializeUnknownTestsNotificationEventFilter(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(TestsNotificationEventFilter)} does not support writing '{options.Format}' format."); + } + } + + TestsNotificationEventFilter 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 DeserializeTestsNotificationEventFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestsNotificationEventFilter)} 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 TestsNotificationEventFilter FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestsNotificationEventFilter(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestsNotificationEventFilter.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestsNotificationEventFilter.cs new file mode 100644 index 000000000000..1ad444347030 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestsNotificationEventFilter.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.Developer.LoadTesting +{ + /// + /// The notification event filter for Tests scope. + /// 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 TestsNotificationEventFilter + { + /// + /// 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 TestsNotificationEventFilter() + { + } + + /// Initializes a new instance of . + /// The event type. + /// Keeps track of any properties unknown to the library. + internal TestsNotificationEventFilter(NotificationEventType kind, IDictionary serializedAdditionalRawData) + { + Kind = kind; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The event type. + internal NotificationEventType Kind { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestsNotificationRule.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestsNotificationRule.Serialization.cs new file mode 100644 index 000000000000..546597f21a51 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestsNotificationRule.Serialization.cs @@ -0,0 +1,236 @@ +// 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.Developer.LoadTesting +{ + public partial class TestsNotificationRule : 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(TestsNotificationRule)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsCollectionDefined(TestIds)) + { + writer.WritePropertyName("testIds"u8); + writer.WriteStartArray(); + foreach (var item in TestIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("eventFilters"u8); + writer.WriteStartObject(); + foreach (var item in EventFilters) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + + TestsNotificationRule 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(TestsNotificationRule)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestsNotificationRule(document.RootElement, options); + } + + internal static TestsNotificationRule DeserializeTestsNotificationRule(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList testIds = default; + IDictionary eventFilters = default; + string notificationRuleId = default; + string displayName = default; + IList actionGroupIds = default; + NotificationScopeType scope = default; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("testIds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + testIds = array; + continue; + } + if (property.NameEquals("eventFilters"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, TestsNotificationEventFilter.DeserializeTestsNotificationEventFilter(property0.Value, options)); + } + eventFilters = dictionary; + continue; + } + if (property.NameEquals("notificationRuleId"u8)) + { + notificationRuleId = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("actionGroupIds"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + actionGroupIds = array; + continue; + } + if (property.NameEquals("scope"u8)) + { + scope = new NotificationScopeType(property.Value.GetString()); + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestsNotificationRule( + notificationRuleId, + displayName, + actionGroupIds, + scope, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData, + testIds ?? new ChangeTrackingList(), + eventFilters); + } + + 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(TestsNotificationRule)} does not support writing '{options.Format}' format."); + } + } + + TestsNotificationRule 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 DeserializeTestsNotificationRule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestsNotificationRule)} 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 TestsNotificationRule FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestsNotificationRule(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestsNotificationRule.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestsNotificationRule.cs new file mode 100644 index 000000000000..cb905ac00236 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TestsNotificationRule.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Tests Notification rule model. + public partial class TestsNotificationRule : NotificationRule + { + /// Initializes a new instance of . + /// The name of the notification rule. + /// The action groups to notify. + /// + /// The event to receive notifications for along with filtering conditions. + /// Key is a user-assigned identifier for the event filter. + /// 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 TestsNotificationRule(string displayName, IEnumerable actionGroupIds, IDictionary eventFilters) : base(displayName, actionGroupIds) + { + Argument.AssertNotNull(displayName, nameof(displayName)); + Argument.AssertNotNull(actionGroupIds, nameof(actionGroupIds)); + Argument.AssertNotNull(eventFilters, nameof(eventFilters)); + + Scope = NotificationScopeType.Tests; + TestIds = new ChangeTrackingList(); + EventFilters = eventFilters; + } + + /// Initializes a new instance of . + /// The unique identifier of the notification rule. + /// The name of the notification rule. + /// The action groups to notify. + /// The scope of the notification rule. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + /// The test ids to include. If not provided, notification will be sent for all testIds. + /// + /// The event to receive notifications for along with filtering conditions. + /// Key is a user-assigned identifier for the event filter. + /// 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 . + /// + internal TestsNotificationRule(string notificationRuleId, string displayName, IList actionGroupIds, NotificationScopeType scope, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData, IList testIds, IDictionary eventFilters) : base(notificationRuleId, displayName, actionGroupIds, scope, createdDateTime, createdBy, lastModifiedDateTime, lastModifiedBy, serializedAdditionalRawData) + { + TestIds = testIds; + EventFilters = eventFilters; + } + + /// Initializes a new instance of for deserialization. + internal TestsNotificationRule() + { + } + + /// The test ids to include. If not provided, notification will be sent for all testIds. + public IList TestIds { get; } + /// + /// The event to receive notifications for along with filtering conditions. + /// Key is a user-assigned identifier for the event filter. + /// 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 IDictionary EventFilters { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TimeGrain.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TimeGrain.cs new file mode 100644 index 000000000000..87c543443180 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TimeGrain.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Time Grain. + public readonly partial struct TimeGrain : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TimeGrain(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FiveSecondsValue = "PT5S"; + private const string TenSecondsValue = "PT10S"; + private const string OneMinuteValue = "PT1M"; + private const string FiveMinutesValue = "PT5M"; + private const string OneHourValue = "PT1H"; + + /// 5 seconds, available only if test run duration is less than 10 minutes. + public static TimeGrain FiveSeconds { get; } = new TimeGrain(FiveSecondsValue); + /// 10 seconds, available only if test run duration is less than 10 minutes. + public static TimeGrain TenSeconds { get; } = new TimeGrain(TenSecondsValue); + /// 1 minute. + public static TimeGrain OneMinute { get; } = new TimeGrain(OneMinuteValue); + /// 5 minutes, available only if test run duration is greater than 1 minute. + public static TimeGrain FiveMinutes { get; } = new TimeGrain(FiveMinutesValue); + /// 1 hour, available only if test run duration is greater than 1 minute. + public static TimeGrain OneHour { get; } = new TimeGrain(OneHourValue); + /// Determines if two values are the same. + public static bool operator ==(TimeGrain left, TimeGrain right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TimeGrain left, TimeGrain right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator TimeGrain(string value) => new TimeGrain(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TimeGrain other && Equals(other); + /// + public bool Equals(TimeGrain 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TimeSeriesElement.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TimeSeriesElement.Serialization.cs new file mode 100644 index 000000000000..781aac916e7e --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TimeSeriesElement.Serialization.cs @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class TimeSeriesElement : 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(TimeSeriesElement)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Data)) + { + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(DimensionValues)) + { + writer.WritePropertyName("dimensionValues"u8); + writer.WriteStartArray(); + foreach (var item in DimensionValues) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TimeSeriesElement 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(TimeSeriesElement)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTimeSeriesElement(document.RootElement, options); + } + + internal static TimeSeriesElement DeserializeTimeSeriesElement(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList data = default; + IReadOnlyList dimensionValues = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("data"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricValue.DeserializeMetricValue(item, options)); + } + data = array; + continue; + } + if (property.NameEquals("dimensionValues"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DimensionValue.DeserializeDimensionValue(item, options)); + } + dimensionValues = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TimeSeriesElement(data ?? new ChangeTrackingList(), dimensionValues ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TimeSeriesElement)} does not support writing '{options.Format}' format."); + } + } + + TimeSeriesElement 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 DeserializeTimeSeriesElement(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TimeSeriesElement)} 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 TimeSeriesElement FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTimeSeriesElement(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TimeSeriesElement.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TimeSeriesElement.cs new file mode 100644 index 000000000000..d8da142d5293 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TimeSeriesElement.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// The time series returned when a data query is performed. + public partial class TimeSeriesElement + { + /// + /// 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 TimeSeriesElement() + { + Data = new ChangeTrackingList(); + DimensionValues = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// An array of data points representing the metric values. + /// The dimension values. + /// Keeps track of any properties unknown to the library. + internal TimeSeriesElement(IReadOnlyList data, IReadOnlyList dimensionValues, IDictionary serializedAdditionalRawData) + { + Data = data; + DimensionValues = dimensionValues; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// An array of data points representing the metric values. + public IReadOnlyList Data { get; } + /// The dimension values. + public IReadOnlyList DimensionValues { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Trigger.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Trigger.Serialization.cs new file mode 100644 index 000000000000..400e58312507 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Trigger.Serialization.cs @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + [PersistableModelProxy(typeof(UnknownTrigger))] + public partial class Trigger : 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(Trigger)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("triggerId"u8); + writer.WriteStringValue(TriggerId); + } + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.ToString()); + if (Optional.IsDefined(State)) + { + writer.WritePropertyName("state"u8); + writer.WriteStringValue(State.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(StateDetails)) + { + writer.WritePropertyName("stateDetails"u8); + writer.WriteObjectValue(StateDetails, options); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedDateTime)) + { + writer.WritePropertyName("lastModifiedDateTime"u8); + writer.WriteStringValue(LastModifiedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedBy)) + { + writer.WritePropertyName("lastModifiedBy"u8); + writer.WriteStringValue(LastModifiedBy); + } + 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 + } + } + } + + Trigger 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(Trigger)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTrigger(document.RootElement, options); + } + + internal static Trigger DeserializeTrigger(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("kind", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "ScheduleTestsTrigger": return ScheduleTestsTrigger.DeserializeScheduleTestsTrigger(element, options); + } + } + return UnknownTrigger.DeserializeUnknownTrigger(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(Trigger)} does not support writing '{options.Format}' format."); + } + } + + Trigger 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 DeserializeTrigger(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Trigger)} 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 Trigger FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTrigger(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/Trigger.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Trigger.cs new file mode 100644 index 000000000000..6feb56ac3fa2 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Trigger.cs @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// + /// Trigger model. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + public abstract partial class Trigger + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The name of the trigger. + /// is null. + protected Trigger(string displayName) + { + Argument.AssertNotNull(displayName, nameof(displayName)); + + DisplayName = displayName; + } + + /// Initializes a new instance of . + /// The unique identifier of the trigger. + /// The name of the trigger. + /// The description of the trigger. + /// The type of the trigger. + /// The current state of the trigger. + /// Details of current state of the trigger. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal Trigger(string triggerId, string displayName, string description, TriggerType kind, TriggerState? state, StateDetails stateDetails, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + { + TriggerId = triggerId; + DisplayName = displayName; + Description = description; + Kind = kind; + State = state; + StateDetails = stateDetails; + CreatedDateTime = createdDateTime; + CreatedBy = createdBy; + LastModifiedDateTime = lastModifiedDateTime; + LastModifiedBy = lastModifiedBy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Trigger() + { + } + + /// The unique identifier of the trigger. + public string TriggerId { get; } + /// The name of the trigger. + public string DisplayName { get; set; } + /// The description of the trigger. + public string Description { get; set; } + /// The type of the trigger. + internal TriggerType Kind { get; set; } + /// The current state of the trigger. + public TriggerState? State { get; set; } + /// Details of current state of the trigger. + public StateDetails StateDetails { get; } + /// The creation datetime(RFC 3339 literal format). + public DateTimeOffset? CreatedDateTime { get; } + /// The user that created. + public string CreatedBy { get; } + /// The last Modified datetime(RFC 3339 literal format). + public DateTimeOffset? LastModifiedDateTime { get; } + /// The user that last modified. + public string LastModifiedBy { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TriggerCompletedNotificationEventFilter.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TriggerCompletedNotificationEventFilter.Serialization.cs new file mode 100644 index 000000000000..776542cb2933 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TriggerCompletedNotificationEventFilter.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class TriggerCompletedNotificationEventFilter : 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(TriggerCompletedNotificationEventFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + TriggerCompletedNotificationEventFilter 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(TriggerCompletedNotificationEventFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTriggerCompletedNotificationEventFilter(document.RootElement, options); + } + + internal static TriggerCompletedNotificationEventFilter DeserializeTriggerCompletedNotificationEventFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + NotificationEventType kind = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("kind"u8)) + { + kind = new NotificationEventType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TriggerCompletedNotificationEventFilter(kind, 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(TriggerCompletedNotificationEventFilter)} does not support writing '{options.Format}' format."); + } + } + + TriggerCompletedNotificationEventFilter 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 DeserializeTriggerCompletedNotificationEventFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TriggerCompletedNotificationEventFilter)} 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 TriggerCompletedNotificationEventFilter FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTriggerCompletedNotificationEventFilter(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TriggerCompletedNotificationEventFilter.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TriggerCompletedNotificationEventFilter.cs new file mode 100644 index 000000000000..110c5e185031 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TriggerCompletedNotificationEventFilter.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// The notification event filter when the event type is TriggerCompleted. + public partial class TriggerCompletedNotificationEventFilter : TestsNotificationEventFilter + { + /// Initializes a new instance of . + public TriggerCompletedNotificationEventFilter() + { + Kind = NotificationEventType.TriggerCompleted; + } + + /// Initializes a new instance of . + /// The event type. + /// Keeps track of any properties unknown to the library. + internal TriggerCompletedNotificationEventFilter(NotificationEventType kind, IDictionary serializedAdditionalRawData) : base(kind, serializedAdditionalRawData) + { + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TriggerDisabledNotificationEventFilter.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TriggerDisabledNotificationEventFilter.Serialization.cs new file mode 100644 index 000000000000..7d896e9ba3ab --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TriggerDisabledNotificationEventFilter.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class TriggerDisabledNotificationEventFilter : 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(TriggerDisabledNotificationEventFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + TriggerDisabledNotificationEventFilter 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(TriggerDisabledNotificationEventFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTriggerDisabledNotificationEventFilter(document.RootElement, options); + } + + internal static TriggerDisabledNotificationEventFilter DeserializeTriggerDisabledNotificationEventFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + NotificationEventType kind = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("kind"u8)) + { + kind = new NotificationEventType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TriggerDisabledNotificationEventFilter(kind, 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(TriggerDisabledNotificationEventFilter)} does not support writing '{options.Format}' format."); + } + } + + TriggerDisabledNotificationEventFilter 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 DeserializeTriggerDisabledNotificationEventFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TriggerDisabledNotificationEventFilter)} 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 TriggerDisabledNotificationEventFilter FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTriggerDisabledNotificationEventFilter(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TriggerDisabledNotificationEventFilter.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TriggerDisabledNotificationEventFilter.cs new file mode 100644 index 000000000000..32b3e34810a9 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TriggerDisabledNotificationEventFilter.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// The notification event filter when the event type is TriggerDisabled. + public partial class TriggerDisabledNotificationEventFilter : TestsNotificationEventFilter + { + /// Initializes a new instance of . + public TriggerDisabledNotificationEventFilter() + { + Kind = NotificationEventType.TriggerDisabled; + } + + /// Initializes a new instance of . + /// The event type. + /// Keeps track of any properties unknown to the library. + internal TriggerDisabledNotificationEventFilter(NotificationEventType kind, IDictionary serializedAdditionalRawData) : base(kind, serializedAdditionalRawData) + { + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TriggerState.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TriggerState.cs new file mode 100644 index 000000000000..5bece83171ef --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TriggerState.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Current state of a trigger. + public readonly partial struct TriggerState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TriggerState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ActiveValue = "Active"; + private const string PausedValue = "Paused"; + private const string CompletedValue = "Completed"; + private const string DisabledValue = "Disabled"; + + /// The trigger is active. + public static TriggerState Active { get; } = new TriggerState(ActiveValue); + /// The trigger is paused manually. + public static TriggerState Paused { get; } = new TriggerState(PausedValue); + /// The trigger is completed. + public static TriggerState Completed { get; } = new TriggerState(CompletedValue); + /// The trigger is disabled due to error. + public static TriggerState Disabled { get; } = new TriggerState(DisabledValue); + /// Determines if two values are the same. + public static bool operator ==(TriggerState left, TriggerState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TriggerState left, TriggerState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator TriggerState(string value) => new TriggerState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TriggerState other && Equals(other); + /// + public bool Equals(TriggerState 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/TriggerType.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TriggerType.cs new file mode 100644 index 000000000000..a39a1e5d0b1e --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/TriggerType.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Type of a trigger. + internal readonly partial struct TriggerType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TriggerType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ScheduleTestsTriggerValue = "ScheduleTestsTrigger"; + + /// Trigger is a Scheduled Trigger on a Test. + public static TriggerType ScheduleTestsTrigger { get; } = new TriggerType(ScheduleTestsTriggerValue); + /// Determines if two values are the same. + public static bool operator ==(TriggerType left, TriggerType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TriggerType left, TriggerType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator TriggerType(string value) => new TriggerType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TriggerType other && Equals(other); + /// + public bool Equals(TriggerType 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownNotificationRule.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownNotificationRule.Serialization.cs new file mode 100644 index 000000000000..c40e95a8d8a7 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownNotificationRule.Serialization.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + internal partial class UnknownNotificationRule : 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(NotificationRule)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + NotificationRule 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(NotificationRule)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNotificationRule(document.RootElement, options); + } + + internal static UnknownNotificationRule DeserializeUnknownNotificationRule(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string notificationRuleId = default; + string displayName = default; + IList actionGroupIds = default; + NotificationScopeType scope = "Unknown"; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("notificationRuleId"u8)) + { + notificationRuleId = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("actionGroupIds"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + actionGroupIds = array; + continue; + } + if (property.NameEquals("scope"u8)) + { + scope = new NotificationScopeType(property.Value.GetString()); + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownNotificationRule( + notificationRuleId, + displayName, + actionGroupIds, + scope, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + 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(NotificationRule)} does not support writing '{options.Format}' format."); + } + } + + NotificationRule 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 DeserializeNotificationRule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NotificationRule)} 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 UnknownNotificationRule FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownNotificationRule(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownNotificationRule.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownNotificationRule.cs new file mode 100644 index 000000000000..b89ffa8fec31 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownNotificationRule.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Unknown version of NotificationRule. + internal partial class UnknownNotificationRule : NotificationRule + { + /// Initializes a new instance of . + /// The unique identifier of the notification rule. + /// The name of the notification rule. + /// The action groups to notify. + /// The scope of the notification rule. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal UnknownNotificationRule(string notificationRuleId, string displayName, IList actionGroupIds, NotificationScopeType scope, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) : base(notificationRuleId, displayName, actionGroupIds, scope, createdDateTime, createdBy, lastModifiedDateTime, lastModifiedBy, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownNotificationRule() + { + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownRecurrence.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownRecurrence.Serialization.cs new file mode 100644 index 000000000000..506fb48eddd0 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownRecurrence.Serialization.cs @@ -0,0 +1,136 @@ +// 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.Developer.LoadTesting +{ + internal partial class UnknownRecurrence : 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(Recurrence)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + Recurrence 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(Recurrence)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRecurrence(document.RootElement, options); + } + + internal static UnknownRecurrence DeserializeUnknownRecurrence(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Frequency frequency = "Unknown"; + RecurrenceEnd recurrenceEnd = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("frequency"u8)) + { + frequency = new Frequency(property.Value.GetString()); + continue; + } + if (property.NameEquals("recurrenceEnd"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownRecurrence(frequency, recurrenceEnd, 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(Recurrence)} does not support writing '{options.Format}' format."); + } + } + + Recurrence 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 DeserializeRecurrence(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Recurrence)} 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 UnknownRecurrence FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownRecurrence(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownRecurrence.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownRecurrence.cs new file mode 100644 index 000000000000..67715845194a --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownRecurrence.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Unknown version of Recurrence. + internal partial class UnknownRecurrence : Recurrence + { + /// Initializes a new instance of . + /// Frequency of the recurrence. + /// Recurrence end model. You can specify the end either by providing a numberOfOccurrences (which will end the recurrence after the specified number of occurrences) or by providing an endDateTime (which will end the recurrence after the specified date). If neither value is provided, the recurrence will continue until it is manually ended. However, if both values are provided, an error will be thrown. + /// Keeps track of any properties unknown to the library. + internal UnknownRecurrence(Frequency frequency, RecurrenceEnd recurrenceEnd, IDictionary serializedAdditionalRawData) : base(frequency, recurrenceEnd, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownRecurrence() + { + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownTargetResourceConfigurations.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownTargetResourceConfigurations.Serialization.cs new file mode 100644 index 000000000000..95ed07c11d9b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownTargetResourceConfigurations.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + internal partial class UnknownTargetResourceConfigurations : 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(TargetResourceConfigurations)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + TargetResourceConfigurations 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(TargetResourceConfigurations)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTargetResourceConfigurations(document.RootElement, options); + } + + internal static UnknownTargetResourceConfigurations DeserializeUnknownTargetResourceConfigurations(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceKind kind = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("kind"u8)) + { + kind = new ResourceKind(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownTargetResourceConfigurations(kind, 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(TargetResourceConfigurations)} does not support writing '{options.Format}' format."); + } + } + + TargetResourceConfigurations 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 DeserializeTargetResourceConfigurations(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TargetResourceConfigurations)} 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 UnknownTargetResourceConfigurations FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownTargetResourceConfigurations(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownTargetResourceConfigurations.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownTargetResourceConfigurations.cs new file mode 100644 index 000000000000..b9bbc8047dc9 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownTargetResourceConfigurations.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Unknown version of TargetResourceConfigurations. + internal partial class UnknownTargetResourceConfigurations : TargetResourceConfigurations + { + /// Initializes a new instance of . + /// Kind of the resource for which the configurations apply. + /// Keeps track of any properties unknown to the library. + internal UnknownTargetResourceConfigurations(ResourceKind kind, IDictionary serializedAdditionalRawData) : base(kind, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownTargetResourceConfigurations() + { + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownTestsNotificationEventFilter.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownTestsNotificationEventFilter.Serialization.cs new file mode 100644 index 000000000000..32062129b68a --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownTestsNotificationEventFilter.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + internal partial class UnknownTestsNotificationEventFilter : 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(TestsNotificationEventFilter)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + TestsNotificationEventFilter 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(TestsNotificationEventFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestsNotificationEventFilter(document.RootElement, options); + } + + internal static UnknownTestsNotificationEventFilter DeserializeUnknownTestsNotificationEventFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + NotificationEventType kind = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("kind"u8)) + { + kind = new NotificationEventType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownTestsNotificationEventFilter(kind, 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(TestsNotificationEventFilter)} does not support writing '{options.Format}' format."); + } + } + + TestsNotificationEventFilter 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 DeserializeTestsNotificationEventFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestsNotificationEventFilter)} 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 UnknownTestsNotificationEventFilter FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownTestsNotificationEventFilter(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownTestsNotificationEventFilter.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownTestsNotificationEventFilter.cs new file mode 100644 index 000000000000..901ee52818b8 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownTestsNotificationEventFilter.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Unknown version of TestsNotificationEventFilter. + internal partial class UnknownTestsNotificationEventFilter : TestsNotificationEventFilter + { + /// Initializes a new instance of . + /// The event type. + /// Keeps track of any properties unknown to the library. + internal UnknownTestsNotificationEventFilter(NotificationEventType kind, IDictionary serializedAdditionalRawData) : base(kind, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownTestsNotificationEventFilter() + { + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownTrigger.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownTrigger.Serialization.cs new file mode 100644 index 000000000000..ac70095f023b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownTrigger.Serialization.cs @@ -0,0 +1,207 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + internal partial class UnknownTrigger : 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(Trigger)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + Trigger 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(Trigger)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTrigger(document.RootElement, options); + } + + internal static UnknownTrigger DeserializeUnknownTrigger(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string triggerId = default; + string displayName = default; + string description = default; + TriggerType kind = "Unknown"; + TriggerState? state = default; + StateDetails stateDetails = default; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("triggerId"u8)) + { + triggerId = 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("kind"u8)) + { + kind = new TriggerType(property.Value.GetString()); + continue; + } + if (property.NameEquals("state"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + state = new TriggerState(property.Value.GetString()); + continue; + } + if (property.NameEquals("stateDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + stateDetails = StateDetails.DeserializeStateDetails(property.Value, options); + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownTrigger( + triggerId, + displayName, + description, + kind, + state, + stateDetails, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + 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(Trigger)} does not support writing '{options.Format}' format."); + } + } + + Trigger 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 DeserializeTrigger(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Trigger)} 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 UnknownTrigger FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownTrigger(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownTrigger.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownTrigger.cs new file mode 100644 index 000000000000..6cc3ae625058 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/UnknownTrigger.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Unknown version of Trigger. + internal partial class UnknownTrigger : Trigger + { + /// Initializes a new instance of . + /// The unique identifier of the trigger. + /// The name of the trigger. + /// The description of the trigger. + /// The type of the trigger. + /// The current state of the trigger. + /// Details of current state of the trigger. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal UnknownTrigger(string triggerId, string displayName, string description, TriggerType kind, TriggerState? state, StateDetails stateDetails, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) : base(triggerId, displayName, description, kind, state, stateDetails, createdDateTime, createdBy, lastModifiedDateTime, lastModifiedBy, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownTrigger() + { + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/WeekDays.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/WeekDays.cs new file mode 100644 index 000000000000..d32f662ec839 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/WeekDays.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting +{ + /// Defines the days of the week. + public readonly partial struct WeekDays : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public WeekDays(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SundayValue = "Sunday"; + private const string MondayValue = "Monday"; + private const string TuesdayValue = "Tuesday"; + private const string WednesdayValue = "Wednesday"; + private const string ThursdayValue = "Thursday"; + private const string FridayValue = "Friday"; + private const string SaturdayValue = "Saturday"; + + /// Refers to Sunday. + public static WeekDays Sunday { get; } = new WeekDays(SundayValue); + /// Refers to Monday. + public static WeekDays Monday { get; } = new WeekDays(MondayValue); + /// Refers to Tuesday. + public static WeekDays Tuesday { get; } = new WeekDays(TuesdayValue); + /// Refers to Wednesday. + public static WeekDays Wednesday { get; } = new WeekDays(WednesdayValue); + /// Refers to Thursday. + public static WeekDays Thursday { get; } = new WeekDays(ThursdayValue); + /// Refers to Friday. + public static WeekDays Friday { get; } = new WeekDays(FridayValue); + /// Refers to Saturday. + public static WeekDays Saturday { get; } = new WeekDays(SaturdayValue); + /// Determines if two values are the same. + public static bool operator ==(WeekDays left, WeekDays right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(WeekDays left, WeekDays right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator WeekDays(string value) => new WeekDays(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is WeekDays other && Equals(other); + /// + public bool Equals(WeekDays 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/loadtesting/Azure.Developer.LoadTesting/src/Generated/WeeklyRecurrence.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/WeeklyRecurrence.Serialization.cs new file mode 100644 index 000000000000..10ea5a219615 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/WeeklyRecurrence.Serialization.cs @@ -0,0 +1,176 @@ +// 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.Developer.LoadTesting +{ + public partial class WeeklyRecurrence : 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(WeeklyRecurrence)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsCollectionDefined(DaysOfWeek)) + { + writer.WritePropertyName("daysOfWeek"u8); + writer.WriteStartArray(); + foreach (var item in DaysOfWeek) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Interval)) + { + writer.WritePropertyName("interval"u8); + writer.WriteNumberValue(Interval.Value); + } + } + + WeeklyRecurrence 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(WeeklyRecurrence)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWeeklyRecurrence(document.RootElement, options); + } + + internal static WeeklyRecurrence DeserializeWeeklyRecurrence(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList daysOfWeek = default; + int? interval = default; + Frequency frequency = default; + RecurrenceEnd recurrenceEnd = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("daysOfWeek"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new WeekDays(item.GetString())); + } + daysOfWeek = array; + continue; + } + if (property.NameEquals("interval"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + interval = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("frequency"u8)) + { + frequency = new Frequency(property.Value.GetString()); + continue; + } + if (property.NameEquals("recurrenceEnd"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WeeklyRecurrence(frequency, recurrenceEnd, serializedAdditionalRawData, daysOfWeek ?? new ChangeTrackingList(), interval); + } + + 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(WeeklyRecurrence)} does not support writing '{options.Format}' format."); + } + } + + WeeklyRecurrence 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 DeserializeWeeklyRecurrence(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WeeklyRecurrence)} 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 WeeklyRecurrence FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWeeklyRecurrence(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/loadtesting/Azure.Developer.LoadTesting/src/Generated/WeeklyRecurrence.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/WeeklyRecurrence.cs new file mode 100644 index 000000000000..756d01a5c2b2 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/WeeklyRecurrence.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Recurrence model when frequency is set as weekly. + public partial class WeeklyRecurrence : Recurrence + { + /// Initializes a new instance of . + public WeeklyRecurrence() + { + Frequency = Frequency.Weekly; + DaysOfWeek = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Frequency of the recurrence. + /// Recurrence end model. You can specify the end either by providing a numberOfOccurrences (which will end the recurrence after the specified number of occurrences) or by providing an endDateTime (which will end the recurrence after the specified date). If neither value is provided, the recurrence will continue until it is manually ended. However, if both values are provided, an error will be thrown. + /// Keeps track of any properties unknown to the library. + /// Recurrence set to repeat on the specified days of the week. + /// The interval at which the recurrence should repeat. It signifies the number of weeks between each recurrence. + internal WeeklyRecurrence(Frequency frequency, RecurrenceEnd recurrenceEnd, IDictionary serializedAdditionalRawData, IList daysOfWeek, int? interval) : base(frequency, recurrenceEnd, serializedAdditionalRawData) + { + DaysOfWeek = daysOfWeek; + Interval = interval; + } + + /// Recurrence set to repeat on the specified days of the week. + public IList DaysOfWeek { get; } + /// The interval at which the recurrence should repeat. It signifies the number of weeks between each recurrence. + public int? Interval { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Properties/AssemblyInfo.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..7a7448111412 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Azure.Developer.LoadTesting.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] + +// Replace Microsoft.Test with the correct resource provider namepace for your service and uncomment. +// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers +// for the list of possible values. +[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Template")] diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/tsp-location.yaml b/sdk/loadtesting/Azure.Developer.LoadTesting/tsp-location.yaml new file mode 100644 index 000000000000..8a4260fa89fc --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/loadtestservice/LoadTestService +commit: 2ad82511706dc035660b16b4754eb4232a9fc4dc +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/loadtesting/ci.yml b/sdk/loadtesting/ci.yml new file mode 100644 index 000000000000..5046481ec78c --- /dev/null +++ b/sdk/loadtesting/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/loadtesting + - sdk/loadtesting/ci.yml + - sdk/loadtesting/Azure.Developer.LoadTesting + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/loadtesting + - sdk/loadtesting/ci.yml + - sdk/loadtesting/Azure.Developer.LoadTesting + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: loadtesting + ArtifactName: packages + Artifacts: + - name: Azure.Developer.LoadTesting + safeName: AzureDeveloperLoadTesting