diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/MIGRATION.md b/sdk/loadtestservice/Azure.Developer.LoadTesting/MIGRATION.md new file mode 100644 index 000000000000..daac146f9d4e --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/MIGRATION.md @@ -0,0 +1,78 @@ +# Migration to @azure-typespec/http-client-csharp Generator + +This document tracks the migration of Azure.Developer.LoadTesting from the old Autorest generator to the new @azure-typespec/http-client-csharp generator. + +## Status: COMPLETED - Code Regeneration + +The SDK has been successfully regenerated using the new @azure-typespec/http-client-csharp generator which uses Azure.Core (not System.ClientModel). + +### Completed Steps + +1. ✅ Updated `tsp-location.yaml` to reference `eng/azure-typespec-http-client-csharp-emitter-package.json` +2. ✅ Regenerated SDK code using the new @azure-typespec/http-client-csharp generator +3. ✅ Verified namespace is correct (Azure.Developer.LoadTesting) +4. ✅ Removed redundant custom pagination methods (now generated) +5. ✅ Updated csproj to maintain Azure.Core compatibility + +### Generated Code Quality + +The new generator produces: +- ✅ Correct Azure.Core-based clients using `TokenCredential` +- ✅ Proper pagination with `Pageable` / `AsyncPageable` +- ✅ All CRUD operations for tests, test runs, and profiles +- ✅ Metrics and monitoring capabilities +- ✅ Proper model serialization/deserialization + +### Remaining Custom Functionality + +The following custom classes need to be preserved or rewritten: + +1. **FileUploadResultOperation.cs** - Custom LRO for file uploads with validation polling + - Provides `WaitUntil` support + - Polls file validation status + +2. **TestRunResultOperation.cs** - Custom LRO for test run execution + - Provides `WaitUntil` support + - Polls test run completion status + +3. **TestProfileRunResultOperation.cs** - Custom LRO for profile run execution + - Provides `WaitUntil` support + - Polls profile run completion status + +4. **LoadTestAdministrationClient.cs** - Custom wrapper methods + - `UploadTestFile` with LRO support + +5. **LoadTestRunClient.cs** - Custom wrapper methods + - `BeginTestRun` with LRO support + - `BeginTestProfileRun` with LRO support + +### API Compatibility + +The generated API has changed: +- Constructor takes `TokenCredential` (from Azure.Identity) instead of endpoint string +- Some method signatures differ slightly (parameter names, order) +- Custom LRO methods not auto-generated + +**Recommendations:** +- These are **breaking changes** +- Plan for a major version bump (2.0.0) +- Provide migration guide for customers +- Custom LRO classes are legitimate value-add and should be retained + +### Build Status + +- Generated code compiles successfully +- API compatibility checks fail (expected due to breaking changes) +- Custom LRO methods need to be added back + +### Next Steps + +1. Restore custom LRO operation classes +2. Add custom wrapper methods for UploadTestFile and BeginTestRun +3. Update API compatibility baseline for 2.0.0 +4. Update tests and samples +5. Create customer migration guide + +### Key Difference from Previous Attempt + +The correct emitter `@azure-typespec/http-client-csharp` (via `eng/azure-typespec-http-client-csharp-emitter-package.json`) generates Azure.Core-based clients, not System.ClientModel-based clients. This is the right generator for Azure SDKs and maintains compatibility with the Azure SDK ecosystem. diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/AutorestCustomizations/AzureDeveloperLoadTestingClientOptions.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/AutorestCustomizations/AzureDeveloperLoadTestingClientOptions.cs deleted file mode 100644 index 832a07de7ec9..000000000000 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/AutorestCustomizations/AzureDeveloperLoadTestingClientOptions.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#nullable disable - -using Azure.Core; - -namespace Azure.Developer.LoadTesting -{ - [CodeGenClient("AzureDeveloperLoadTestingClientOptions")] - public partial class LoadTestingClientOptions{ } -} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/AutorestCustomizations/LoadTestAdministrationClient.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/AutorestCustomizations/LoadTestAdministrationClient.cs deleted file mode 100644 index 6b5853909dae..000000000000 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/AutorestCustomizations/LoadTestAdministrationClient.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; -using Azure.Core; - -namespace Azure.Developer.LoadTesting -{ - [CodeGenSuppress("GetTestsAsync", typeof(string), typeof(string), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(int?), typeof(RequestContext))] - [CodeGenSuppress("GetTests", typeof(string), typeof(string), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(int?), typeof(RequestContext))] - [CodeGenSuppress("GetTestsAsync", typeof(string), typeof(string), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(int?), typeof(CancellationToken))] - [CodeGenSuppress("GetTests", typeof(string), typeof(string), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(int?), typeof(CancellationToken))] - [CodeGenSuppress("GetTestProfiles", typeof(int?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(IEnumerable), typeof(IEnumerable), typeof(RequestContext))] - [CodeGenSuppress("GetTestProfilesAsync", typeof(int?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(IEnumerable), typeof(IEnumerable), typeof(RequestContext))] - [CodeGenSuppress("GetTestProfiles", typeof(int?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(IEnumerable), typeof(IEnumerable), typeof(CancellationToken))] - [CodeGenSuppress("GetTestProfilesAsync", typeof(int?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(IEnumerable), typeof(IEnumerable), typeof(CancellationToken))] - public partial class LoadTestAdministrationClient - { - } -} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/AutorestCustomizations/LoadTestRunClient.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/AutorestCustomizations/LoadTestRunClient.cs deleted file mode 100644 index 4bf5098a7d53..000000000000 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/AutorestCustomizations/LoadTestRunClient.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Threading; -using Azure.Core; - -namespace Azure.Developer.LoadTesting -{ - [CodeGenSuppress("GetTestRunsAsync", typeof(string), typeof(string), typeof(string), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(string), typeof(int?), typeof(RequestContext))] - [CodeGenSuppress("GetTestRuns", typeof(string), typeof(string), typeof(string), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(string), typeof(int?), typeof(RequestContext))] - [CodeGenSuppress("GetTestRunsAsync", typeof(string), typeof(string), typeof(string), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(string), typeof(int?), typeof(CancellationToken))] - [CodeGenSuppress("GetTestRuns", typeof(string), typeof(string), typeof(string), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(string), typeof(int?), typeof(CancellationToken))] - [CodeGenSuppress("GetTestProfileRuns", typeof(int?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(IEnumerable), typeof(IEnumerable), typeof(IEnumerable), typeof(RequestContext))] - [CodeGenSuppress("GetTestProfileRunsAsync", typeof(int?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(IEnumerable), typeof(IEnumerable), typeof(IEnumerable), typeof(RequestContext))] - [CodeGenSuppress("GetTestProfileRuns", typeof(int?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(IEnumerable), typeof(IEnumerable), typeof(IEnumerable), typeof(CancellationToken))] - [CodeGenSuppress("GetTestProfileRunsAsync", typeof(int?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(IEnumerable), typeof(IEnumerable), typeof(IEnumerable), typeof(CancellationToken))] - public partial class LoadTestRunClient - { - } -} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/AutorestCustomizations/LoadTestingClientBuilderExtensions.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/AutorestCustomizations/LoadTestingClientBuilderExtensions.cs deleted file mode 100644 index 4d343177bea0..000000000000 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/AutorestCustomizations/LoadTestingClientBuilderExtensions.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#nullable disable - -using Azure.Core; - -namespace Microsoft.Extensions.Azure -{ - [CodeGenType("DeveloperLoadTestingClientBuilderExtensions")] // change the name back here to avoid breaking changes. - public static partial class AzureLoadTestingClientBuilderExtensions - { - } -} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/AutorestCustomizations/LoadTestingModelFactory.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/AutorestCustomizations/LoadTestingModelFactory.cs deleted file mode 100644 index bae25c9a6f00..000000000000 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/AutorestCustomizations/LoadTestingModelFactory.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using Azure.Core; - -namespace Azure.Developer.LoadTesting -{ - /// Model factory for models. - [CodeGenClient("DeveloperLoadTestingModelFactory")] - public partial class LoadTestingModelFactory { } -} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Azure.Developer.LoadTesting.csproj b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Azure.Developer.LoadTesting.csproj index 2b324514cbf5..da71af706075 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Azure.Developer.LoadTesting.csproj +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Azure.Developer.LoadTesting.csproj @@ -9,7 +9,6 @@ $(RequiredTargetFrameworks) true $(NoWarn);AZC0034 - true true diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/FileUploadResultOperation.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Custom/FileUploadResultOperation.cs similarity index 100% rename from sdk/loadtestservice/Azure.Developer.LoadTesting/src/FileUploadResultOperation.cs rename to sdk/loadtestservice/Azure.Developer.LoadTesting/src/Custom/FileUploadResultOperation.cs diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/GlobalSuppressions.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Custom/GlobalSuppressions.cs similarity index 100% rename from sdk/loadtestservice/Azure.Developer.LoadTesting/src/GlobalSuppressions.cs rename to sdk/loadtestservice/Azure.Developer.LoadTesting/src/Custom/GlobalSuppressions.cs diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Custom/LoadTestAdministrationClient.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Custom/LoadTestAdministrationClient.cs new file mode 100644 index 000000000000..b4d2ae4dc989 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Custom/LoadTestAdministrationClient.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class 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 LoadTestingClientOptions()) + { + } + + /// 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, LoadTestingClientOptions options) + : this(endpoint?.Host, credential, options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Custom/LoadTestRunClient.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Custom/LoadTestRunClient.cs new file mode 100644 index 000000000000..deda4cff3eca --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Custom/LoadTestRunClient.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + public partial class 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 LoadTestingClientOptions()) + { + } + + /// 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, LoadTestingClientOptions options) + : this(endpoint?.Host, credential, options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/TestProfileRunResultOperation.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Custom/TestProfileRunResultOperation.cs similarity index 100% rename from sdk/loadtestservice/Azure.Developer.LoadTesting/src/TestProfileRunResultOperation.cs rename to sdk/loadtestservice/Azure.Developer.LoadTesting/src/Custom/TestProfileRunResultOperation.cs diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/TestRunResultOperation.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Custom/TestRunResultOperation.cs similarity index 100% rename from sdk/loadtestservice/Azure.Developer.LoadTesting/src/TestRunResultOperation.cs rename to sdk/loadtestservice/Azure.Developer.LoadTesting/src/Custom/TestRunResultOperation.cs diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/AggregationType.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/AggregationType.cs index 76917e3b3797..8f74092b236f 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/AggregationType.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/AggregationType.cs @@ -14,71 +14,112 @@ namespace Azure.Developer.LoadTesting 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)); - } - + /// Average value. private const string AverageValue = "Average"; + /// Total count. private const string CountValue = "Count"; + /// Aggregation will be average in this case. private const string NoneValue = "None"; + /// Total sum. private const string TotalValue = "Total"; + /// 75th percentile. private const string Percentile75Value = "Percentile75"; + /// 90th percentile. private const string Percentile90Value = "Percentile90"; + /// 95th percentile. private const string Percentile95Value = "Percentile95"; + /// 96th percentile. private const string Percentile96Value = "Percentile96"; + /// 97th percentile. private const string Percentile97Value = "Percentile97"; + /// 98th percentile. private const string Percentile98Value = "Percentile98"; + /// 99th percentile. private const string Percentile99Value = "Percentile99"; + /// 99.9th percentile. private const string Percentile999Value = "Percentile999"; + /// 99.99th percentile. private const string Percentile9999Value = "Percentile9999"; + /// Initializes a new instance of . + /// The value. + /// is null. + public AggregationType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(AggregationType left, AggregationType right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(AggregationType left, AggregationType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator AggregationType(string value) => new AggregationType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator AggregationType?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ArtifactsContainerInfo.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ArtifactsContainerInfo.Serialization.cs index 3eb4cbc2223b..fd23e419739a 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ArtifactsContainerInfo.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ArtifactsContainerInfo.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Artifacts container info. + public partial class ArtifactsContainerInfo : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader /// 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; + string 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); @@ -44,15 +43,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("expireDateTime"u8); writer.WriteStringValue(ExpiresOn.Value, "O"); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,63 +60,69 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ArtifactsContainerInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ArtifactsContainerInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ArtifactsContainerInfo JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ArtifactsContainerInfo DeserializeArtifactsContainerInfo(JsonElement element, ModelReaderWriterOptions options) { - 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()) + Uri uri = default; + DateTimeOffset? expiresOn = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("url"u8)) + if (prop.NameEquals("url"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - url = new Uri(property.Value.GetString()); + uri = new Uri(prop.Value.GetString()); continue; } - if (property.NameEquals("expireDateTime"u8)) + if (prop.NameEquals("expireDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - expireDateTime = property.Value.GetDateTimeOffset("O"); + expiresOn = prop.Value.GetDateTimeOffset("O"); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new ArtifactsContainerInfo(url, expireDateTime, serializedAdditionalRawData); + return new ArtifactsContainerInfo(uri, expiresOn, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -127,15 +132,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - ArtifactsContainerInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + ArtifactsContainerInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ArtifactsContainerInfo PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeArtifactsContainerInfo(document.RootElement, options); } default: @@ -143,22 +153,7 @@ ArtifactsContainerInfo IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ArtifactsContainerInfo.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ArtifactsContainerInfo.cs index 6c3025c73388..d3286ca23813 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ArtifactsContainerInfo.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ArtifactsContainerInfo.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal ArtifactsContainerInfo() @@ -53,16 +24,17 @@ 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) + /// Keeps track of any properties unknown to the library. + internal ArtifactsContainerInfo(Uri uri, DateTimeOffset? expiresOn, IDictionary additionalBinaryDataProperties) { Uri = uri; ExpiresOn = expiresOn; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/AutoStopCriteria.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/AutoStopCriteria.Serialization.cs index c23755aff7f5..0ca1755ea285 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/AutoStopCriteria.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/AutoStopCriteria.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// 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 : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter /// 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; + string 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); @@ -47,22 +46,22 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (Optional.IsDefined(ErrorRateTimeWindow)) { writer.WritePropertyName("errorRateTimeWindowInSeconds"u8); - writer.WriteNumberValue(Convert.ToInt32(ErrorRateTimeWindow.Value.ToString("%s"))); + writer.WriteNumberValue(Convert.ToInt32(ErrorRateTimeWindow.Value.TotalSeconds)); } if (Optional.IsDefined(MaximumVirtualUsersPerEngine)) { writer.WritePropertyName("maximumVirtualUsersPerEngine"u8); writer.WriteNumberValue(MaximumVirtualUsersPerEngine.Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -71,83 +70,89 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - AutoStopCriteria IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + AutoStopCriteria IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AutoStopCriteria JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AutoStopCriteria DeserializeAutoStopCriteria(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } bool? autoStopDisabled = default; float? errorRate = default; - TimeSpan? errorRateTimeWindowInSeconds = default; + TimeSpan? errorRateTimeWindow = default; int? maximumVirtualUsersPerEngine = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("autoStopDisabled"u8)) + if (prop.NameEquals("autoStopDisabled"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - autoStopDisabled = property.Value.GetBoolean(); + autoStopDisabled = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("errorRate"u8)) + if (prop.NameEquals("errorRate"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - errorRate = property.Value.GetSingle(); + errorRate = prop.Value.GetSingle(); continue; } - if (property.NameEquals("errorRateTimeWindowInSeconds"u8)) + if (prop.NameEquals("errorRateTimeWindowInSeconds"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - errorRateTimeWindowInSeconds = TimeSpan.FromSeconds(property.Value.GetInt32()); + errorRateTimeWindow = TimeSpan.FromSeconds(prop.Value.GetInt32()); continue; } - if (property.NameEquals("maximumVirtualUsersPerEngine"u8)) + if (prop.NameEquals("maximumVirtualUsersPerEngine"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - maximumVirtualUsersPerEngine = property.Value.GetInt32(); + maximumVirtualUsersPerEngine = prop.Value.GetInt32(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new AutoStopCriteria(autoStopDisabled, errorRate, errorRateTimeWindowInSeconds, maximumVirtualUsersPerEngine, serializedAdditionalRawData); + return new AutoStopCriteria(autoStopDisabled, errorRate, errorRateTimeWindow, maximumVirtualUsersPerEngine, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -157,15 +162,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions op } } - AutoStopCriteria IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + AutoStopCriteria IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AutoStopCriteria PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeAutoStopCriteria(document.RootElement, options); } default: @@ -173,22 +183,7 @@ AutoStopCriteria IPersistableModel.Create(BinaryData data, Mod } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/AutoStopCriteria.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/AutoStopCriteria.cs index 5acc1601f85f..d202b424dc2b 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/AutoStopCriteria.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/AutoStopCriteria.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public AutoStopCriteria() @@ -55,22 +26,25 @@ public AutoStopCriteria() /// 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) + /// Keeps track of any properties unknown to the library. + internal AutoStopCriteria(bool? autoStopDisabled, float? errorRate, TimeSpan? errorRateTimeWindow, int? maximumVirtualUsersPerEngine, IDictionary additionalBinaryDataProperties) { AutoStopDisabled = autoStopDisabled; ErrorRate = errorRate; ErrorRateTimeWindow = errorRateTimeWindow; MaximumVirtualUsersPerEngine = maximumVirtualUsersPerEngine; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CertificateType.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CertificateType.cs index 2d4b2cc0ea64..c21f7a2fb5de 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CertificateType.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CertificateType.cs @@ -14,35 +14,52 @@ namespace Azure.Developer.LoadTesting public readonly partial struct CertificateType : IEquatable { private readonly string _value; + /// If the certificate is stored in an Azure Key Vault. + private const string KeyVaultCertificateUriValue = "AKV_CERT_URI"; /// Initializes a new instance of . + /// The value. /// is null. public CertificateType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string KeyVaultCertificateUriValue = "AKV_CERT_URI"; + _value = value; + } /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(CertificateType left, CertificateType right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(CertificateType left, CertificateType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator CertificateType(string value) => new CertificateType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator CertificateType?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CloneTestRequest1.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CloneTestRequest1.Serialization.cs index 332728b5b99f..6368fc9c3691 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CloneTestRequest1.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CloneTestRequest1.Serialization.cs @@ -13,10 +13,16 @@ namespace Azure.Developer.LoadTesting { - internal partial class CloneTestRequest1 : IUtf8JsonSerializable, IJsonModel + /// The CloneTestRequest1. + internal partial class CloneTestRequest1 : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal CloneTestRequest1() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +34,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite /// 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; + string 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)) @@ -46,15 +51,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("description"u8); writer.WriteStringValue(Description); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -63,22 +68,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - CloneTestRequest1 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + CloneTestRequest1 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual CloneTestRequest1 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static CloneTestRequest1 DeserializeCloneTestRequest1(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -86,38 +96,39 @@ internal static CloneTestRequest1 DeserializeCloneTestRequest1(JsonElement eleme string newTestId = default; string displayName = default; string description = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("newTestId"u8)) + if (prop.NameEquals("newTestId"u8)) { - newTestId = property.Value.GetString(); + newTestId = prop.Value.GetString(); continue; } - if (property.NameEquals("displayName"u8)) + if (prop.NameEquals("displayName"u8)) { - displayName = property.Value.GetString(); + displayName = prop.Value.GetString(); continue; } - if (property.NameEquals("description"u8)) + if (prop.NameEquals("description"u8)) { - description = property.Value.GetString(); + description = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new CloneTestRequest1(newTestId, displayName, description, serializedAdditionalRawData); + return new CloneTestRequest1(newTestId, displayName, description, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -127,15 +138,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o } } - CloneTestRequest1 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + CloneTestRequest1 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual CloneTestRequest1 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeCloneTestRequest1(document.RootElement, options); } default: @@ -143,21 +159,18 @@ CloneTestRequest1 IPersistableModel.Create(BinaryData data, M } } + /// The client options for reading and writing models. 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) + /// The to serialize into . + public static implicit operator RequestContent(CloneTestRequest1 cloneTestRequest1) { - 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); + if (cloneTestRequest1 == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(cloneTestRequest1, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CloneTestRequest1.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CloneTestRequest1.cs index 1360cf440431..540563c220c9 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CloneTestRequest1.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CloneTestRequest1.cs @@ -13,45 +13,13 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// 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; } @@ -59,24 +27,21 @@ internal CloneTestRequest1(string newTestId) /// 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) + /// Keeps track of any properties unknown to the library. + internal CloneTestRequest1(string newTestId, string displayName, string description, IDictionary additionalBinaryDataProperties) { NewTestId = newTestId; DisplayName = displayName; Description = description; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal CloneTestRequest1() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetNotificationRulesAsyncCollectionResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetNotificationRulesAsyncCollectionResult.cs new file mode 100644 index 000000000000..6d4f85046577 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetNotificationRulesAsyncCollectionResult.cs @@ -0,0 +1,95 @@ +// 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.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetNotificationRulesAsyncCollectionResult : AsyncPageable + { + private readonly LoadTestAdministrationClient _client; + private readonly string _testIds; + private readonly string _scopes; + private readonly DateTimeOffset? _lastModifiedStartTime; + private readonly DateTimeOffset? _lastModifiedEndTime; + private readonly int? _maxpagesize; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetNotificationRulesAsyncCollectionResult, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestAdministrationClientGetNotificationRulesAsyncCollectionResult(LoadTestAdministrationClient client, string testIds, string scopes, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _testIds = testIds; + _scopes = scopes; + _lastModifiedStartTime = lastModifiedStartTime; + _lastModifiedEndTime = lastModifiedEndTime; + _maxpagesize = maxpagesize; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetNotificationRulesAsyncCollectionResult as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetNotificationRulesAsyncCollectionResult as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + PagedNotificationRule result = (PagedNotificationRule)response; + List items = new List(); + foreach (var item in result.Value) + { + items.Add(ModelReaderWriter.Write(item, ModelSerializationExtensions.WireOptions, AzureDeveloperLoadTestingContext.Default)); + } + yield return Page.FromValues(items, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetNotificationRulesRequest(nextLink, _testIds, _scopes, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context) : _client.CreateGetNotificationRulesRequest(_testIds, _scopes, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetNotificationRules"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetNotificationRulesAsyncCollectionResultOfT.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetNotificationRulesAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..7ea4cfc60062 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetNotificationRulesAsyncCollectionResultOfT.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetNotificationRulesAsyncCollectionResultOfT : AsyncPageable + { + private readonly LoadTestAdministrationClient _client; + private readonly string _testIds; + private readonly string _scopes; + private readonly DateTimeOffset? _lastModifiedStartTime; + private readonly DateTimeOffset? _lastModifiedEndTime; + private readonly int? _maxpagesize; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetNotificationRulesAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestAdministrationClientGetNotificationRulesAsyncCollectionResultOfT(LoadTestAdministrationClient client, string testIds, string scopes, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _testIds = testIds; + _scopes = scopes; + _lastModifiedStartTime = lastModifiedStartTime; + _lastModifiedEndTime = lastModifiedEndTime; + _maxpagesize = maxpagesize; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetNotificationRulesAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetNotificationRulesAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + PagedNotificationRule result = (PagedNotificationRule)response; + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetNotificationRulesRequest(nextLink, _testIds, _scopes, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context) : _client.CreateGetNotificationRulesRequest(_testIds, _scopes, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetNotificationRules"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetNotificationRulesCollectionResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetNotificationRulesCollectionResult.cs new file mode 100644 index 000000000000..8c992c1e7f0b --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetNotificationRulesCollectionResult.cs @@ -0,0 +1,94 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetNotificationRulesCollectionResult : Pageable + { + private readonly LoadTestAdministrationClient _client; + private readonly string _testIds; + private readonly string _scopes; + private readonly DateTimeOffset? _lastModifiedStartTime; + private readonly DateTimeOffset? _lastModifiedEndTime; + private readonly int? _maxpagesize; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetNotificationRulesCollectionResult, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestAdministrationClientGetNotificationRulesCollectionResult(LoadTestAdministrationClient client, string testIds, string scopes, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _testIds = testIds; + _scopes = scopes; + _lastModifiedStartTime = lastModifiedStartTime; + _lastModifiedEndTime = lastModifiedEndTime; + _maxpagesize = maxpagesize; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetNotificationRulesCollectionResult as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetNotificationRulesCollectionResult as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + PagedNotificationRule result = (PagedNotificationRule)response; + List items = new List(); + foreach (var item in result.Value) + { + items.Add(ModelReaderWriter.Write(item, ModelSerializationExtensions.WireOptions, AzureDeveloperLoadTestingContext.Default)); + } + yield return Page.FromValues(items, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetNotificationRulesRequest(nextLink, _testIds, _scopes, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context) : _client.CreateGetNotificationRulesRequest(_testIds, _scopes, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetNotificationRules"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetNotificationRulesCollectionResultOfT.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetNotificationRulesCollectionResultOfT.cs new file mode 100644 index 000000000000..4014ffac7812 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetNotificationRulesCollectionResultOfT.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetNotificationRulesCollectionResultOfT : Pageable + { + private readonly LoadTestAdministrationClient _client; + private readonly string _testIds; + private readonly string _scopes; + private readonly DateTimeOffset? _lastModifiedStartTime; + private readonly DateTimeOffset? _lastModifiedEndTime; + private readonly int? _maxpagesize; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetNotificationRulesCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestAdministrationClientGetNotificationRulesCollectionResultOfT(LoadTestAdministrationClient client, string testIds, string scopes, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _testIds = testIds; + _scopes = scopes; + _lastModifiedStartTime = lastModifiedStartTime; + _lastModifiedEndTime = lastModifiedEndTime; + _maxpagesize = maxpagesize; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetNotificationRulesCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetNotificationRulesCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + PagedNotificationRule result = (PagedNotificationRule)response; + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetNotificationRulesRequest(nextLink, _testIds, _scopes, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context) : _client.CreateGetNotificationRulesRequest(_testIds, _scopes, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetNotificationRules"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestFilesAsyncCollectionResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestFilesAsyncCollectionResult.cs new file mode 100644 index 000000000000..d22217a957e5 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestFilesAsyncCollectionResult.cs @@ -0,0 +1,87 @@ +// 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.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetTestFilesAsyncCollectionResult : AsyncPageable + { + private readonly LoadTestAdministrationClient _client; + private readonly string _testId; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetTestFilesAsyncCollectionResult, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request options, 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. + public LoadTestAdministrationClientGetTestFilesAsyncCollectionResult(LoadTestAdministrationClient client, string testId, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + _client = client; + _testId = testId; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetTestFilesAsyncCollectionResult as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetTestFilesAsyncCollectionResult as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + PagedTestFileInfo result = (PagedTestFileInfo)response; + List items = new List(); + foreach (var item in result.Value) + { + items.Add(ModelReaderWriter.Write(item, ModelSerializationExtensions.WireOptions, AzureDeveloperLoadTestingContext.Default)); + } + yield return Page.FromValues(items, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestFilesRequest(nextLink, _testId, _context) : _client.CreateGetTestFilesRequest(_testId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestFiles"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestFilesAsyncCollectionResultOfT.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestFilesAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..4d9303cc0a9c --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestFilesAsyncCollectionResultOfT.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetTestFilesAsyncCollectionResultOfT : AsyncPageable + { + private readonly LoadTestAdministrationClient _client; + private readonly string _testId; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetTestFilesAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request options, 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. + public LoadTestAdministrationClientGetTestFilesAsyncCollectionResultOfT(LoadTestAdministrationClient client, string testId, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + _client = client; + _testId = testId; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetTestFilesAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetTestFilesAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + PagedTestFileInfo result = (PagedTestFileInfo)response; + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestFilesRequest(nextLink, _testId, _context) : _client.CreateGetTestFilesRequest(_testId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestFiles"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestFilesCollectionResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestFilesCollectionResult.cs new file mode 100644 index 000000000000..0bdc9f6fa17c --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestFilesCollectionResult.cs @@ -0,0 +1,86 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetTestFilesCollectionResult : Pageable + { + private readonly LoadTestAdministrationClient _client; + private readonly string _testId; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetTestFilesCollectionResult, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request options, 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. + public LoadTestAdministrationClientGetTestFilesCollectionResult(LoadTestAdministrationClient client, string testId, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + _client = client; + _testId = testId; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetTestFilesCollectionResult as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetTestFilesCollectionResult as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + PagedTestFileInfo result = (PagedTestFileInfo)response; + List items = new List(); + foreach (var item in result.Value) + { + items.Add(ModelReaderWriter.Write(item, ModelSerializationExtensions.WireOptions, AzureDeveloperLoadTestingContext.Default)); + } + yield return Page.FromValues(items, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestFilesRequest(nextLink, _testId, _context) : _client.CreateGetTestFilesRequest(_testId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestFiles"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestFilesCollectionResultOfT.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestFilesCollectionResultOfT.cs new file mode 100644 index 000000000000..2746398f7d4c --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestFilesCollectionResultOfT.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetTestFilesCollectionResultOfT : Pageable + { + private readonly LoadTestAdministrationClient _client; + private readonly string _testId; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetTestFilesCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request options, 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. + public LoadTestAdministrationClientGetTestFilesCollectionResultOfT(LoadTestAdministrationClient client, string testId, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + _client = client; + _testId = testId; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetTestFilesCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetTestFilesCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + PagedTestFileInfo result = (PagedTestFileInfo)response; + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestFilesRequest(nextLink, _testId, _context) : _client.CreateGetTestFilesRequest(_testId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestFiles"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestProfilesAsyncCollectionResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestProfilesAsyncCollectionResult.cs new file mode 100644 index 000000000000..f6e44bffb6fd --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestProfilesAsyncCollectionResult.cs @@ -0,0 +1,95 @@ +// 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.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetTestProfilesAsyncCollectionResult : AsyncPageable + { + private readonly LoadTestAdministrationClient _client; + private readonly int? _maxpagesize; + private readonly DateTimeOffset? _lastModifiedStartTime; + private readonly DateTimeOffset? _lastModifiedEndTime; + private readonly IEnumerable _testProfileIds; + private readonly IEnumerable _testIds; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetTestProfilesAsyncCollectionResult, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestAdministrationClientGetTestProfilesAsyncCollectionResult(LoadTestAdministrationClient client, int? maxpagesize, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, IEnumerable testProfileIds, IEnumerable testIds, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _maxpagesize = maxpagesize; + _lastModifiedStartTime = lastModifiedStartTime; + _lastModifiedEndTime = lastModifiedEndTime; + _testProfileIds = testProfileIds; + _testIds = testIds; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetTestProfilesAsyncCollectionResult as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetTestProfilesAsyncCollectionResult as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + PagedTestProfile result = (PagedTestProfile)response; + List items = new List(); + foreach (var item in result.Value) + { + items.Add(ModelReaderWriter.Write(item, ModelSerializationExtensions.WireOptions, AzureDeveloperLoadTestingContext.Default)); + } + yield return Page.FromValues(items, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestProfilesRequest(nextLink, _maxpagesize, _lastModifiedStartTime, _lastModifiedEndTime, _testProfileIds, _testIds, _context) : _client.CreateGetTestProfilesRequest(_maxpagesize, _lastModifiedStartTime, _lastModifiedEndTime, _testProfileIds, _testIds, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestProfiles"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestProfilesAsyncCollectionResultOfT.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestProfilesAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..f9a1d35db31b --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestProfilesAsyncCollectionResultOfT.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetTestProfilesAsyncCollectionResultOfT : AsyncPageable + { + private readonly LoadTestAdministrationClient _client; + private readonly int? _maxpagesize; + private readonly DateTimeOffset? _lastModifiedStartTime; + private readonly DateTimeOffset? _lastModifiedEndTime; + private readonly IEnumerable _testProfileIds; + private readonly IEnumerable _testIds; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetTestProfilesAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestAdministrationClientGetTestProfilesAsyncCollectionResultOfT(LoadTestAdministrationClient client, int? maxpagesize, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, IEnumerable testProfileIds, IEnumerable testIds, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _maxpagesize = maxpagesize; + _lastModifiedStartTime = lastModifiedStartTime; + _lastModifiedEndTime = lastModifiedEndTime; + _testProfileIds = testProfileIds; + _testIds = testIds; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetTestProfilesAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetTestProfilesAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + PagedTestProfile result = (PagedTestProfile)response; + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestProfilesRequest(nextLink, _maxpagesize, _lastModifiedStartTime, _lastModifiedEndTime, _testProfileIds, _testIds, _context) : _client.CreateGetTestProfilesRequest(_maxpagesize, _lastModifiedStartTime, _lastModifiedEndTime, _testProfileIds, _testIds, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestProfiles"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestProfilesCollectionResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestProfilesCollectionResult.cs new file mode 100644 index 000000000000..094d1b242f94 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestProfilesCollectionResult.cs @@ -0,0 +1,94 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetTestProfilesCollectionResult : Pageable + { + private readonly LoadTestAdministrationClient _client; + private readonly int? _maxpagesize; + private readonly DateTimeOffset? _lastModifiedStartTime; + private readonly DateTimeOffset? _lastModifiedEndTime; + private readonly IEnumerable _testProfileIds; + private readonly IEnumerable _testIds; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetTestProfilesCollectionResult, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestAdministrationClientGetTestProfilesCollectionResult(LoadTestAdministrationClient client, int? maxpagesize, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, IEnumerable testProfileIds, IEnumerable testIds, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _maxpagesize = maxpagesize; + _lastModifiedStartTime = lastModifiedStartTime; + _lastModifiedEndTime = lastModifiedEndTime; + _testProfileIds = testProfileIds; + _testIds = testIds; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetTestProfilesCollectionResult as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetTestProfilesCollectionResult as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + PagedTestProfile result = (PagedTestProfile)response; + List items = new List(); + foreach (var item in result.Value) + { + items.Add(ModelReaderWriter.Write(item, ModelSerializationExtensions.WireOptions, AzureDeveloperLoadTestingContext.Default)); + } + yield return Page.FromValues(items, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestProfilesRequest(nextLink, _maxpagesize, _lastModifiedStartTime, _lastModifiedEndTime, _testProfileIds, _testIds, _context) : _client.CreateGetTestProfilesRequest(_maxpagesize, _lastModifiedStartTime, _lastModifiedEndTime, _testProfileIds, _testIds, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestProfiles"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestProfilesCollectionResultOfT.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestProfilesCollectionResultOfT.cs new file mode 100644 index 000000000000..8bc0274bcc2b --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestProfilesCollectionResultOfT.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetTestProfilesCollectionResultOfT : Pageable + { + private readonly LoadTestAdministrationClient _client; + private readonly int? _maxpagesize; + private readonly DateTimeOffset? _lastModifiedStartTime; + private readonly DateTimeOffset? _lastModifiedEndTime; + private readonly IEnumerable _testProfileIds; + private readonly IEnumerable _testIds; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetTestProfilesCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestAdministrationClientGetTestProfilesCollectionResultOfT(LoadTestAdministrationClient client, int? maxpagesize, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, IEnumerable testProfileIds, IEnumerable testIds, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _maxpagesize = maxpagesize; + _lastModifiedStartTime = lastModifiedStartTime; + _lastModifiedEndTime = lastModifiedEndTime; + _testProfileIds = testProfileIds; + _testIds = testIds; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetTestProfilesCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetTestProfilesCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + PagedTestProfile result = (PagedTestProfile)response; + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestProfilesRequest(nextLink, _maxpagesize, _lastModifiedStartTime, _lastModifiedEndTime, _testProfileIds, _testIds, _context) : _client.CreateGetTestProfilesRequest(_maxpagesize, _lastModifiedStartTime, _lastModifiedEndTime, _testProfileIds, _testIds, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestProfiles"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestsAsyncCollectionResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestsAsyncCollectionResult.cs new file mode 100644 index 000000000000..9246a0dc4743 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestsAsyncCollectionResult.cs @@ -0,0 +1,102 @@ +// 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.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetTestsAsyncCollectionResult : AsyncPageable + { + private readonly LoadTestAdministrationClient _client; + private readonly string _orderby; + private readonly string _search; + private readonly DateTimeOffset? _lastModifiedStartTime; + private readonly DateTimeOffset? _lastModifiedEndTime; + private readonly int? _maxpagesize; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetTestsAsyncCollectionResult, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestAdministrationClientGetTestsAsyncCollectionResult(LoadTestAdministrationClient client, string @orderby, string search, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _orderby = @orderby; + _search = search; + _lastModifiedStartTime = lastModifiedStartTime; + _lastModifiedEndTime = lastModifiedEndTime; + _maxpagesize = maxpagesize; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetTestsAsyncCollectionResult as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetTestsAsyncCollectionResult as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + PagedTest result = (PagedTest)response; + List items = new List(); + foreach (var item in result.Value) + { + items.Add(ModelReaderWriter.Write(item, ModelSerializationExtensions.WireOptions, AzureDeveloperLoadTestingContext.Default)); + } + yield return Page.FromValues(items, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestsRequest(nextLink, _orderby, _search, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context) : _client.CreateGetTestsRequest(_orderby, _search, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTests"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestsAsyncCollectionResultOfT.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestsAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..0b84e5343c36 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestsAsyncCollectionResultOfT.cs @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetTestsAsyncCollectionResultOfT : AsyncPageable + { + private readonly LoadTestAdministrationClient _client; + private readonly string _orderby; + private readonly string _search; + private readonly DateTimeOffset? _lastModifiedStartTime; + private readonly DateTimeOffset? _lastModifiedEndTime; + private readonly int? _maxpagesize; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetTestsAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestAdministrationClientGetTestsAsyncCollectionResultOfT(LoadTestAdministrationClient client, string @orderby, string search, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _orderby = @orderby; + _search = search; + _lastModifiedStartTime = lastModifiedStartTime; + _lastModifiedEndTime = lastModifiedEndTime; + _maxpagesize = maxpagesize; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetTestsAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetTestsAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + PagedTest result = (PagedTest)response; + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestsRequest(nextLink, _orderby, _search, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context) : _client.CreateGetTestsRequest(_orderby, _search, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTests"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestsCollectionResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestsCollectionResult.cs new file mode 100644 index 000000000000..8b29a4b0b734 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestsCollectionResult.cs @@ -0,0 +1,101 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetTestsCollectionResult : Pageable + { + private readonly LoadTestAdministrationClient _client; + private readonly string _orderby; + private readonly string _search; + private readonly DateTimeOffset? _lastModifiedStartTime; + private readonly DateTimeOffset? _lastModifiedEndTime; + private readonly int? _maxpagesize; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetTestsCollectionResult, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestAdministrationClientGetTestsCollectionResult(LoadTestAdministrationClient client, string @orderby, string search, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _orderby = @orderby; + _search = search; + _lastModifiedStartTime = lastModifiedStartTime; + _lastModifiedEndTime = lastModifiedEndTime; + _maxpagesize = maxpagesize; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetTestsCollectionResult as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetTestsCollectionResult as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + PagedTest result = (PagedTest)response; + List items = new List(); + foreach (var item in result.Value) + { + items.Add(ModelReaderWriter.Write(item, ModelSerializationExtensions.WireOptions, AzureDeveloperLoadTestingContext.Default)); + } + yield return Page.FromValues(items, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestsRequest(nextLink, _orderby, _search, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context) : _client.CreateGetTestsRequest(_orderby, _search, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTests"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestsCollectionResultOfT.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestsCollectionResultOfT.cs new file mode 100644 index 000000000000..7e88b558399e --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTestsCollectionResultOfT.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; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetTestsCollectionResultOfT : Pageable + { + private readonly LoadTestAdministrationClient _client; + private readonly string _orderby; + private readonly string _search; + private readonly DateTimeOffset? _lastModifiedStartTime; + private readonly DateTimeOffset? _lastModifiedEndTime; + private readonly int? _maxpagesize; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetTestsCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestAdministrationClientGetTestsCollectionResultOfT(LoadTestAdministrationClient client, string @orderby, string search, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _orderby = @orderby; + _search = search; + _lastModifiedStartTime = lastModifiedStartTime; + _lastModifiedEndTime = lastModifiedEndTime; + _maxpagesize = maxpagesize; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetTestsCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetTestsCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + PagedTest result = (PagedTest)response; + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestsRequest(nextLink, _orderby, _search, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context) : _client.CreateGetTestsRequest(_orderby, _search, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTests"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTriggersAsyncCollectionResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTriggersAsyncCollectionResult.cs new file mode 100644 index 000000000000..882eae2a2892 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTriggersAsyncCollectionResult.cs @@ -0,0 +1,95 @@ +// 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.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetTriggersAsyncCollectionResult : AsyncPageable + { + private readonly LoadTestAdministrationClient _client; + private readonly string _testIds; + private readonly string _states; + private readonly DateTimeOffset? _lastModifiedStartTime; + private readonly DateTimeOffset? _lastModifiedEndTime; + private readonly int? _maxpagesize; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetTriggersAsyncCollectionResult, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// 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 request options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestAdministrationClientGetTriggersAsyncCollectionResult(LoadTestAdministrationClient client, string testIds, string states, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _testIds = testIds; + _states = states; + _lastModifiedStartTime = lastModifiedStartTime; + _lastModifiedEndTime = lastModifiedEndTime; + _maxpagesize = maxpagesize; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetTriggersAsyncCollectionResult as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetTriggersAsyncCollectionResult as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + PagedTrigger result = (PagedTrigger)response; + List items = new List(); + foreach (var item in result.Value) + { + items.Add(ModelReaderWriter.Write(item, ModelSerializationExtensions.WireOptions, AzureDeveloperLoadTestingContext.Default)); + } + yield return Page.FromValues(items, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTriggersRequest(nextLink, _testIds, _states, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context) : _client.CreateGetTriggersRequest(_testIds, _states, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTriggers"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTriggersAsyncCollectionResultOfT.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTriggersAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..47b6d28bd399 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTriggersAsyncCollectionResultOfT.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetTriggersAsyncCollectionResultOfT : AsyncPageable + { + private readonly LoadTestAdministrationClient _client; + private readonly string _testIds; + private readonly string _states; + private readonly DateTimeOffset? _lastModifiedStartTime; + private readonly DateTimeOffset? _lastModifiedEndTime; + private readonly int? _maxpagesize; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetTriggersAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// 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 request options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestAdministrationClientGetTriggersAsyncCollectionResultOfT(LoadTestAdministrationClient client, string testIds, string states, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _testIds = testIds; + _states = states; + _lastModifiedStartTime = lastModifiedStartTime; + _lastModifiedEndTime = lastModifiedEndTime; + _maxpagesize = maxpagesize; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetTriggersAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetTriggersAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + PagedTrigger result = (PagedTrigger)response; + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTriggersRequest(nextLink, _testIds, _states, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context) : _client.CreateGetTriggersRequest(_testIds, _states, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTriggers"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTriggersCollectionResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTriggersCollectionResult.cs new file mode 100644 index 000000000000..79d8a27b6078 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTriggersCollectionResult.cs @@ -0,0 +1,94 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetTriggersCollectionResult : Pageable + { + private readonly LoadTestAdministrationClient _client; + private readonly string _testIds; + private readonly string _states; + private readonly DateTimeOffset? _lastModifiedStartTime; + private readonly DateTimeOffset? _lastModifiedEndTime; + private readonly int? _maxpagesize; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetTriggersCollectionResult, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// 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 request options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestAdministrationClientGetTriggersCollectionResult(LoadTestAdministrationClient client, string testIds, string states, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _testIds = testIds; + _states = states; + _lastModifiedStartTime = lastModifiedStartTime; + _lastModifiedEndTime = lastModifiedEndTime; + _maxpagesize = maxpagesize; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetTriggersCollectionResult as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetTriggersCollectionResult as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + PagedTrigger result = (PagedTrigger)response; + List items = new List(); + foreach (var item in result.Value) + { + items.Add(ModelReaderWriter.Write(item, ModelSerializationExtensions.WireOptions, AzureDeveloperLoadTestingContext.Default)); + } + yield return Page.FromValues(items, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTriggersRequest(nextLink, _testIds, _states, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context) : _client.CreateGetTriggersRequest(_testIds, _states, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTriggers"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTriggersCollectionResultOfT.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTriggersCollectionResultOfT.cs new file mode 100644 index 000000000000..ad18a1dd8e2a --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestAdministrationClientGetTriggersCollectionResultOfT.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestAdministrationClientGetTriggersCollectionResultOfT : Pageable + { + private readonly LoadTestAdministrationClient _client; + private readonly string _testIds; + private readonly string _states; + private readonly DateTimeOffset? _lastModifiedStartTime; + private readonly DateTimeOffset? _lastModifiedEndTime; + private readonly int? _maxpagesize; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestAdministrationClientGetTriggersCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LoadTestAdministrationClient client used to send requests. + /// 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 request options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestAdministrationClientGetTriggersCollectionResultOfT(LoadTestAdministrationClient client, string testIds, string states, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _testIds = testIds; + _states = states; + _lastModifiedStartTime = lastModifiedStartTime; + _lastModifiedEndTime = lastModifiedEndTime; + _maxpagesize = maxpagesize; + _context = context; + } + + /// Gets the pages of LoadTestAdministrationClientGetTriggersCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestAdministrationClientGetTriggersCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + PagedTrigger result = (PagedTrigger)response; + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTriggersRequest(nextLink, _testIds, _states, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context) : _client.CreateGetTriggersRequest(_testIds, _states, _lastModifiedStartTime, _lastModifiedEndTime, _maxpagesize, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTriggers"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricDimensionValuesAsyncCollectionResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricDimensionValuesAsyncCollectionResult.cs new file mode 100644 index 000000000000..bec931f93364 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricDimensionValuesAsyncCollectionResult.cs @@ -0,0 +1,109 @@ +// 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.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestRunClientGetMetricDimensionValuesAsyncCollectionResult : AsyncPageable + { + private readonly LoadTestRunClient _client; + private readonly string _testRunId; + private readonly string _name; + private readonly string _metricname; + private readonly string _metricNamespace; + private readonly string _timespan; + private readonly string _interval; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestRunClientGetMetricDimensionValuesAsyncCollectionResult, which is used to iterate over the pages of a collection. + /// The LoadTestRunClient client used to send requests. + /// + /// 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 request options, 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. + public LoadTestRunClientGetMetricDimensionValuesAsyncCollectionResult(LoadTestRunClient client, string testRunId, string name, string metricname, string metricNamespace, string timespan, string interval, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(metricname, nameof(metricname)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNullOrEmpty(timespan, nameof(timespan)); + + _client = client; + _testRunId = testRunId; + _name = name; + _metricname = metricname; + _metricNamespace = metricNamespace; + _timespan = timespan; + _interval = interval; + _context = context; + } + + /// Gets the pages of LoadTestRunClientGetMetricDimensionValuesAsyncCollectionResult as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestRunClientGetMetricDimensionValuesAsyncCollectionResult as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + DimensionValueList result = (DimensionValueList)response; + List items = new List(); + foreach (var item in result.Value) + { + items.Add(ModelReaderWriter.Write(item, ModelSerializationExtensions.WireOptions, AzureDeveloperLoadTestingContext.Default)); + } + yield return Page.FromValues(items, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetMetricDimensionValuesRequest(nextLink, _testRunId, _name, _metricname, _metricNamespace, _timespan, _interval, _context) : _client.CreateGetMetricDimensionValuesRequest(_testRunId, _name, _metricname, _metricNamespace, _timespan, _interval, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricDimensionValues"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricDimensionValuesAsyncCollectionResultOfT.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricDimensionValuesAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..dc3e63dd4d97 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricDimensionValuesAsyncCollectionResultOfT.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 System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestRunClientGetMetricDimensionValuesAsyncCollectionResultOfT : AsyncPageable + { + private readonly LoadTestRunClient _client; + private readonly string _testRunId; + private readonly string _name; + private readonly string _metricname; + private readonly string _metricNamespace; + private readonly string _timespan; + private readonly string _interval; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestRunClientGetMetricDimensionValuesAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LoadTestRunClient client used to send requests. + /// + /// 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 request options, 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. + public LoadTestRunClientGetMetricDimensionValuesAsyncCollectionResultOfT(LoadTestRunClient client, string testRunId, string name, string metricname, string metricNamespace, string timespan, string interval, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(metricname, nameof(metricname)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNullOrEmpty(timespan, nameof(timespan)); + + _client = client; + _testRunId = testRunId; + _name = name; + _metricname = metricname; + _metricNamespace = metricNamespace; + _timespan = timespan; + _interval = interval; + _context = context; + } + + /// Gets the pages of LoadTestRunClientGetMetricDimensionValuesAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestRunClientGetMetricDimensionValuesAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + DimensionValueList result = (DimensionValueList)response; + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetMetricDimensionValuesRequest(nextLink, _testRunId, _name, _metricname, _metricNamespace, _timespan, _interval, _context) : _client.CreateGetMetricDimensionValuesRequest(_testRunId, _name, _metricname, _metricNamespace, _timespan, _interval, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricDimensionValues"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricDimensionValuesCollectionResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricDimensionValuesCollectionResult.cs new file mode 100644 index 000000000000..695e6bd043ae --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricDimensionValuesCollectionResult.cs @@ -0,0 +1,108 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestRunClientGetMetricDimensionValuesCollectionResult : Pageable + { + private readonly LoadTestRunClient _client; + private readonly string _testRunId; + private readonly string _name; + private readonly string _metricname; + private readonly string _metricNamespace; + private readonly string _timespan; + private readonly string _interval; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestRunClientGetMetricDimensionValuesCollectionResult, which is used to iterate over the pages of a collection. + /// The LoadTestRunClient client used to send requests. + /// + /// 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 request options, 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. + public LoadTestRunClientGetMetricDimensionValuesCollectionResult(LoadTestRunClient client, string testRunId, string name, string metricname, string metricNamespace, string timespan, string interval, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(metricname, nameof(metricname)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNullOrEmpty(timespan, nameof(timespan)); + + _client = client; + _testRunId = testRunId; + _name = name; + _metricname = metricname; + _metricNamespace = metricNamespace; + _timespan = timespan; + _interval = interval; + _context = context; + } + + /// Gets the pages of LoadTestRunClientGetMetricDimensionValuesCollectionResult as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestRunClientGetMetricDimensionValuesCollectionResult as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + DimensionValueList result = (DimensionValueList)response; + List items = new List(); + foreach (var item in result.Value) + { + items.Add(ModelReaderWriter.Write(item, ModelSerializationExtensions.WireOptions, AzureDeveloperLoadTestingContext.Default)); + } + yield return Page.FromValues(items, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetMetricDimensionValuesRequest(nextLink, _testRunId, _name, _metricname, _metricNamespace, _timespan, _interval, _context) : _client.CreateGetMetricDimensionValuesRequest(_testRunId, _name, _metricname, _metricNamespace, _timespan, _interval, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricDimensionValues"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricDimensionValuesCollectionResultOfT.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricDimensionValuesCollectionResultOfT.cs new file mode 100644 index 000000000000..eb4a2f2b3c14 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricDimensionValuesCollectionResultOfT.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; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestRunClientGetMetricDimensionValuesCollectionResultOfT : Pageable + { + private readonly LoadTestRunClient _client; + private readonly string _testRunId; + private readonly string _name; + private readonly string _metricname; + private readonly string _metricNamespace; + private readonly string _timespan; + private readonly string _interval; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestRunClientGetMetricDimensionValuesCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LoadTestRunClient client used to send requests. + /// + /// 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 request options, 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. + public LoadTestRunClientGetMetricDimensionValuesCollectionResultOfT(LoadTestRunClient client, string testRunId, string name, string metricname, string metricNamespace, string timespan, string interval, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(metricname, nameof(metricname)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNullOrEmpty(timespan, nameof(timespan)); + + _client = client; + _testRunId = testRunId; + _name = name; + _metricname = metricname; + _metricNamespace = metricNamespace; + _timespan = timespan; + _interval = interval; + _context = context; + } + + /// Gets the pages of LoadTestRunClientGetMetricDimensionValuesCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestRunClientGetMetricDimensionValuesCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + DimensionValueList result = (DimensionValueList)response; + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetMetricDimensionValuesRequest(nextLink, _testRunId, _name, _metricname, _metricNamespace, _timespan, _interval, _context) : _client.CreateGetMetricDimensionValuesRequest(_testRunId, _name, _metricname, _metricNamespace, _timespan, _interval, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricDimensionValues"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricsAsyncCollectionResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricsAsyncCollectionResult.cs new file mode 100644 index 000000000000..2897656459b2 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricsAsyncCollectionResult.cs @@ -0,0 +1,112 @@ +// 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.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestRunClientGetMetricsAsyncCollectionResult : AsyncPageable + { + private readonly LoadTestRunClient _client; + private readonly string _testRunId; + private readonly string _metricname; + private readonly string _metricNamespace; + private readonly string _timespan; + private readonly RequestContent _content; + private readonly string _aggregation; + private readonly string _interval; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestRunClientGetMetricsAsyncCollectionResult, which is used to iterate over the pages of a collection. + /// The LoadTestRunClient client used to send requests. + /// + /// 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. + /// The request options, 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. + public LoadTestRunClientGetMetricsAsyncCollectionResult(LoadTestRunClient client, string testRunId, string metricname, string metricNamespace, string timespan, RequestContent content, string aggregation, string interval, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(metricname, nameof(metricname)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNullOrEmpty(timespan, nameof(timespan)); + Argument.AssertNotNull(content, nameof(content)); + + _client = client; + _testRunId = testRunId; + _metricname = metricname; + _metricNamespace = metricNamespace; + _timespan = timespan; + _content = content; + _aggregation = aggregation; + _interval = interval; + _context = context; + } + + /// Gets the pages of LoadTestRunClientGetMetricsAsyncCollectionResult as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestRunClientGetMetricsAsyncCollectionResult as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + Metrics result = (Metrics)response; + List items = new List(); + foreach (var item in result.Value) + { + items.Add(ModelReaderWriter.Write(item, ModelSerializationExtensions.WireOptions, AzureDeveloperLoadTestingContext.Default)); + } + yield return Page.FromValues(items, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetMetricsRequest(nextLink, _testRunId, _metricname, _metricNamespace, _timespan, _content, _aggregation, _interval, _context) : _client.CreateGetMetricsRequest(_testRunId, _metricname, _metricNamespace, _timespan, _content, _aggregation, _interval, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetrics"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricsAsyncCollectionResultOfT.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricsAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..394d44fa35e2 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricsAsyncCollectionResultOfT.cs @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestRunClientGetMetricsAsyncCollectionResultOfT : AsyncPageable + { + private readonly LoadTestRunClient _client; + private readonly string _testRunId; + private readonly string _metricname; + private readonly string _metricNamespace; + private readonly string _timespan; + private readonly RequestContent _content; + private readonly string _aggregation; + private readonly string _interval; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestRunClientGetMetricsAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LoadTestRunClient client used to send requests. + /// + /// 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. + /// The request options, 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. + public LoadTestRunClientGetMetricsAsyncCollectionResultOfT(LoadTestRunClient client, string testRunId, string metricname, string metricNamespace, string timespan, RequestContent content, string aggregation, string interval, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(metricname, nameof(metricname)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNullOrEmpty(timespan, nameof(timespan)); + Argument.AssertNotNull(content, nameof(content)); + + _client = client; + _testRunId = testRunId; + _metricname = metricname; + _metricNamespace = metricNamespace; + _timespan = timespan; + _content = content; + _aggregation = aggregation; + _interval = interval; + _context = context; + } + + /// Gets the pages of LoadTestRunClientGetMetricsAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestRunClientGetMetricsAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + Metrics result = (Metrics)response; + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetMetricsRequest(nextLink, _testRunId, _metricname, _metricNamespace, _timespan, _content, _aggregation, _interval, _context) : _client.CreateGetMetricsRequest(_testRunId, _metricname, _metricNamespace, _timespan, _content, _aggregation, _interval, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetrics"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricsCollectionResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricsCollectionResult.cs new file mode 100644 index 000000000000..4149686ac481 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricsCollectionResult.cs @@ -0,0 +1,111 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestRunClientGetMetricsCollectionResult : Pageable + { + private readonly LoadTestRunClient _client; + private readonly string _testRunId; + private readonly string _metricname; + private readonly string _metricNamespace; + private readonly string _timespan; + private readonly RequestContent _content; + private readonly string _aggregation; + private readonly string _interval; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestRunClientGetMetricsCollectionResult, which is used to iterate over the pages of a collection. + /// The LoadTestRunClient client used to send requests. + /// + /// 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. + /// The request options, 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. + public LoadTestRunClientGetMetricsCollectionResult(LoadTestRunClient client, string testRunId, string metricname, string metricNamespace, string timespan, RequestContent content, string aggregation, string interval, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(metricname, nameof(metricname)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNullOrEmpty(timespan, nameof(timespan)); + Argument.AssertNotNull(content, nameof(content)); + + _client = client; + _testRunId = testRunId; + _metricname = metricname; + _metricNamespace = metricNamespace; + _timespan = timespan; + _content = content; + _aggregation = aggregation; + _interval = interval; + _context = context; + } + + /// Gets the pages of LoadTestRunClientGetMetricsCollectionResult as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestRunClientGetMetricsCollectionResult as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + Metrics result = (Metrics)response; + List items = new List(); + foreach (var item in result.Value) + { + items.Add(ModelReaderWriter.Write(item, ModelSerializationExtensions.WireOptions, AzureDeveloperLoadTestingContext.Default)); + } + yield return Page.FromValues(items, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetMetricsRequest(nextLink, _testRunId, _metricname, _metricNamespace, _timespan, _content, _aggregation, _interval, _context) : _client.CreateGetMetricsRequest(_testRunId, _metricname, _metricNamespace, _timespan, _content, _aggregation, _interval, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetrics"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricsCollectionResultOfT.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricsCollectionResultOfT.cs new file mode 100644 index 000000000000..246fa991bef5 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetMetricsCollectionResultOfT.cs @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestRunClientGetMetricsCollectionResultOfT : Pageable + { + private readonly LoadTestRunClient _client; + private readonly string _testRunId; + private readonly string _metricname; + private readonly string _metricNamespace; + private readonly string _timespan; + private readonly RequestContent _content; + private readonly string _aggregation; + private readonly string _interval; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestRunClientGetMetricsCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LoadTestRunClient client used to send requests. + /// + /// 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. + /// The request options, 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. + public LoadTestRunClientGetMetricsCollectionResultOfT(LoadTestRunClient client, string testRunId, string metricname, string metricNamespace, string timespan, RequestContent content, string aggregation, string interval, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(metricname, nameof(metricname)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNullOrEmpty(timespan, nameof(timespan)); + Argument.AssertNotNull(content, nameof(content)); + + _client = client; + _testRunId = testRunId; + _metricname = metricname; + _metricNamespace = metricNamespace; + _timespan = timespan; + _content = content; + _aggregation = aggregation; + _interval = interval; + _context = context; + } + + /// Gets the pages of LoadTestRunClientGetMetricsCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestRunClientGetMetricsCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + Metrics result = (Metrics)response; + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetMetricsRequest(nextLink, _testRunId, _metricname, _metricNamespace, _timespan, _content, _aggregation, _interval, _context) : _client.CreateGetMetricsRequest(_testRunId, _metricname, _metricNamespace, _timespan, _content, _aggregation, _interval, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetrics"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestProfileRunsAsyncCollectionResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestProfileRunsAsyncCollectionResult.cs new file mode 100644 index 000000000000..8675878adb1b --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestProfileRunsAsyncCollectionResult.cs @@ -0,0 +1,110 @@ +// 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.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestRunClientGetTestProfileRunsAsyncCollectionResult : AsyncPageable + { + private readonly LoadTestRunClient _client; + private readonly int? _maxpagesize; + private readonly DateTimeOffset? _minStartDateTime; + private readonly DateTimeOffset? _maxStartDateTime; + private readonly DateTimeOffset? _minEndDateTime; + private readonly DateTimeOffset? _maxEndDateTime; + private readonly DateTimeOffset? _createdDateStartTime; + private readonly DateTimeOffset? _createdDateEndTime; + private readonly IEnumerable _testProfileRunIds; + private readonly IEnumerable _testProfileIds; + private readonly IEnumerable _statuses; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestRunClientGetTestProfileRunsAsyncCollectionResult, which is used to iterate over the pages of a collection. + /// The LoadTestRunClient client used to send requests. + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestRunClientGetTestProfileRunsAsyncCollectionResult(LoadTestRunClient client, int? maxpagesize, DateTimeOffset? minStartDateTime, DateTimeOffset? maxStartDateTime, DateTimeOffset? minEndDateTime, DateTimeOffset? maxEndDateTime, DateTimeOffset? createdDateStartTime, DateTimeOffset? createdDateEndTime, IEnumerable testProfileRunIds, IEnumerable testProfileIds, IEnumerable statuses, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _maxpagesize = maxpagesize; + _minStartDateTime = minStartDateTime; + _maxStartDateTime = maxStartDateTime; + _minEndDateTime = minEndDateTime; + _maxEndDateTime = maxEndDateTime; + _createdDateStartTime = createdDateStartTime; + _createdDateEndTime = createdDateEndTime; + _testProfileRunIds = testProfileRunIds; + _testProfileIds = testProfileIds; + _statuses = statuses; + _context = context; + } + + /// Gets the pages of LoadTestRunClientGetTestProfileRunsAsyncCollectionResult as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestRunClientGetTestProfileRunsAsyncCollectionResult as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + PagedTestProfileRun result = (PagedTestProfileRun)response; + List items = new List(); + foreach (var item in result.Value) + { + items.Add(ModelReaderWriter.Write(item, ModelSerializationExtensions.WireOptions, AzureDeveloperLoadTestingContext.Default)); + } + yield return Page.FromValues(items, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestProfileRunsRequest(nextLink, _maxpagesize, _minStartDateTime, _maxStartDateTime, _minEndDateTime, _maxEndDateTime, _createdDateStartTime, _createdDateEndTime, _testProfileRunIds, _testProfileIds, _statuses, _context) : _client.CreateGetTestProfileRunsRequest(_maxpagesize, _minStartDateTime, _maxStartDateTime, _minEndDateTime, _maxEndDateTime, _createdDateStartTime, _createdDateEndTime, _testProfileRunIds, _testProfileIds, _statuses, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestProfileRuns"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestProfileRunsAsyncCollectionResultOfT.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestProfileRunsAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..e83bb25f090e --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestProfileRunsAsyncCollectionResultOfT.cs @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestRunClientGetTestProfileRunsAsyncCollectionResultOfT : AsyncPageable + { + private readonly LoadTestRunClient _client; + private readonly int? _maxpagesize; + private readonly DateTimeOffset? _minStartDateTime; + private readonly DateTimeOffset? _maxStartDateTime; + private readonly DateTimeOffset? _minEndDateTime; + private readonly DateTimeOffset? _maxEndDateTime; + private readonly DateTimeOffset? _createdDateStartTime; + private readonly DateTimeOffset? _createdDateEndTime; + private readonly IEnumerable _testProfileRunIds; + private readonly IEnumerable _testProfileIds; + private readonly IEnumerable _statuses; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestRunClientGetTestProfileRunsAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LoadTestRunClient client used to send requests. + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestRunClientGetTestProfileRunsAsyncCollectionResultOfT(LoadTestRunClient client, int? maxpagesize, DateTimeOffset? minStartDateTime, DateTimeOffset? maxStartDateTime, DateTimeOffset? minEndDateTime, DateTimeOffset? maxEndDateTime, DateTimeOffset? createdDateStartTime, DateTimeOffset? createdDateEndTime, IEnumerable testProfileRunIds, IEnumerable testProfileIds, IEnumerable statuses, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _maxpagesize = maxpagesize; + _minStartDateTime = minStartDateTime; + _maxStartDateTime = maxStartDateTime; + _minEndDateTime = minEndDateTime; + _maxEndDateTime = maxEndDateTime; + _createdDateStartTime = createdDateStartTime; + _createdDateEndTime = createdDateEndTime; + _testProfileRunIds = testProfileRunIds; + _testProfileIds = testProfileIds; + _statuses = statuses; + _context = context; + } + + /// Gets the pages of LoadTestRunClientGetTestProfileRunsAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestRunClientGetTestProfileRunsAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + PagedTestProfileRun result = (PagedTestProfileRun)response; + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestProfileRunsRequest(nextLink, _maxpagesize, _minStartDateTime, _maxStartDateTime, _minEndDateTime, _maxEndDateTime, _createdDateStartTime, _createdDateEndTime, _testProfileRunIds, _testProfileIds, _statuses, _context) : _client.CreateGetTestProfileRunsRequest(_maxpagesize, _minStartDateTime, _maxStartDateTime, _minEndDateTime, _maxEndDateTime, _createdDateStartTime, _createdDateEndTime, _testProfileRunIds, _testProfileIds, _statuses, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestProfileRuns"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestProfileRunsCollectionResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestProfileRunsCollectionResult.cs new file mode 100644 index 000000000000..f9fe6eb3deb8 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestProfileRunsCollectionResult.cs @@ -0,0 +1,109 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestRunClientGetTestProfileRunsCollectionResult : Pageable + { + private readonly LoadTestRunClient _client; + private readonly int? _maxpagesize; + private readonly DateTimeOffset? _minStartDateTime; + private readonly DateTimeOffset? _maxStartDateTime; + private readonly DateTimeOffset? _minEndDateTime; + private readonly DateTimeOffset? _maxEndDateTime; + private readonly DateTimeOffset? _createdDateStartTime; + private readonly DateTimeOffset? _createdDateEndTime; + private readonly IEnumerable _testProfileRunIds; + private readonly IEnumerable _testProfileIds; + private readonly IEnumerable _statuses; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestRunClientGetTestProfileRunsCollectionResult, which is used to iterate over the pages of a collection. + /// The LoadTestRunClient client used to send requests. + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestRunClientGetTestProfileRunsCollectionResult(LoadTestRunClient client, int? maxpagesize, DateTimeOffset? minStartDateTime, DateTimeOffset? maxStartDateTime, DateTimeOffset? minEndDateTime, DateTimeOffset? maxEndDateTime, DateTimeOffset? createdDateStartTime, DateTimeOffset? createdDateEndTime, IEnumerable testProfileRunIds, IEnumerable testProfileIds, IEnumerable statuses, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _maxpagesize = maxpagesize; + _minStartDateTime = minStartDateTime; + _maxStartDateTime = maxStartDateTime; + _minEndDateTime = minEndDateTime; + _maxEndDateTime = maxEndDateTime; + _createdDateStartTime = createdDateStartTime; + _createdDateEndTime = createdDateEndTime; + _testProfileRunIds = testProfileRunIds; + _testProfileIds = testProfileIds; + _statuses = statuses; + _context = context; + } + + /// Gets the pages of LoadTestRunClientGetTestProfileRunsCollectionResult as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestRunClientGetTestProfileRunsCollectionResult as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + PagedTestProfileRun result = (PagedTestProfileRun)response; + List items = new List(); + foreach (var item in result.Value) + { + items.Add(ModelReaderWriter.Write(item, ModelSerializationExtensions.WireOptions, AzureDeveloperLoadTestingContext.Default)); + } + yield return Page.FromValues(items, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestProfileRunsRequest(nextLink, _maxpagesize, _minStartDateTime, _maxStartDateTime, _minEndDateTime, _maxEndDateTime, _createdDateStartTime, _createdDateEndTime, _testProfileRunIds, _testProfileIds, _statuses, _context) : _client.CreateGetTestProfileRunsRequest(_maxpagesize, _minStartDateTime, _maxStartDateTime, _minEndDateTime, _maxEndDateTime, _createdDateStartTime, _createdDateEndTime, _testProfileRunIds, _testProfileIds, _statuses, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestProfileRuns"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestProfileRunsCollectionResultOfT.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestProfileRunsCollectionResultOfT.cs new file mode 100644 index 000000000000..00ef75340a35 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestProfileRunsCollectionResultOfT.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; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestRunClientGetTestProfileRunsCollectionResultOfT : Pageable + { + private readonly LoadTestRunClient _client; + private readonly int? _maxpagesize; + private readonly DateTimeOffset? _minStartDateTime; + private readonly DateTimeOffset? _maxStartDateTime; + private readonly DateTimeOffset? _minEndDateTime; + private readonly DateTimeOffset? _maxEndDateTime; + private readonly DateTimeOffset? _createdDateStartTime; + private readonly DateTimeOffset? _createdDateEndTime; + private readonly IEnumerable _testProfileRunIds; + private readonly IEnumerable _testProfileIds; + private readonly IEnumerable _statuses; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestRunClientGetTestProfileRunsCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LoadTestRunClient client used to send requests. + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestRunClientGetTestProfileRunsCollectionResultOfT(LoadTestRunClient client, int? maxpagesize, DateTimeOffset? minStartDateTime, DateTimeOffset? maxStartDateTime, DateTimeOffset? minEndDateTime, DateTimeOffset? maxEndDateTime, DateTimeOffset? createdDateStartTime, DateTimeOffset? createdDateEndTime, IEnumerable testProfileRunIds, IEnumerable testProfileIds, IEnumerable statuses, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _maxpagesize = maxpagesize; + _minStartDateTime = minStartDateTime; + _maxStartDateTime = maxStartDateTime; + _minEndDateTime = minEndDateTime; + _maxEndDateTime = maxEndDateTime; + _createdDateStartTime = createdDateStartTime; + _createdDateEndTime = createdDateEndTime; + _testProfileRunIds = testProfileRunIds; + _testProfileIds = testProfileIds; + _statuses = statuses; + _context = context; + } + + /// Gets the pages of LoadTestRunClientGetTestProfileRunsCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestRunClientGetTestProfileRunsCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + PagedTestProfileRun result = (PagedTestProfileRun)response; + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestProfileRunsRequest(nextLink, _maxpagesize, _minStartDateTime, _maxStartDateTime, _minEndDateTime, _maxEndDateTime, _createdDateStartTime, _createdDateEndTime, _testProfileRunIds, _testProfileIds, _statuses, _context) : _client.CreateGetTestProfileRunsRequest(_maxpagesize, _minStartDateTime, _maxStartDateTime, _minEndDateTime, _maxEndDateTime, _createdDateStartTime, _createdDateEndTime, _testProfileRunIds, _testProfileIds, _statuses, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestProfileRuns"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestRunsAsyncCollectionResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestRunsAsyncCollectionResult.cs new file mode 100644 index 000000000000..1a2719b87ad4 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestRunsAsyncCollectionResult.cs @@ -0,0 +1,114 @@ +// 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.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestRunClientGetTestRunsAsyncCollectionResult : AsyncPageable + { + private readonly LoadTestRunClient _client; + private readonly string _orderby; + private readonly string _search; + private readonly string _testId; + private readonly DateTimeOffset? _executionFrom; + private readonly DateTimeOffset? _executionTo; + private readonly string _status; + private readonly int? _maxpagesize; + private readonly IEnumerable _createdByTypes; + private readonly IEnumerable _testIds; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestRunClientGetTestRunsAsyncCollectionResult, which is used to iterate over the pages of a collection. + /// The LoadTestRunClient client used to send requests. + /// + /// 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. + /// Comma-separated list of test IDs. If you are using testIds, do not send a value for testId. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestRunClientGetTestRunsAsyncCollectionResult(LoadTestRunClient client, string @orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, int? maxpagesize, IEnumerable createdByTypes, IEnumerable testIds, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _orderby = @orderby; + _search = search; + _testId = testId; + _executionFrom = executionFrom; + _executionTo = executionTo; + _status = status; + _maxpagesize = maxpagesize; + _createdByTypes = createdByTypes; + _testIds = testIds; + _context = context; + } + + /// Gets the pages of LoadTestRunClientGetTestRunsAsyncCollectionResult as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestRunClientGetTestRunsAsyncCollectionResult as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + PagedTestRun result = (PagedTestRun)response; + List items = new List(); + foreach (var item in result.Value) + { + items.Add(ModelReaderWriter.Write(item, ModelSerializationExtensions.WireOptions, AzureDeveloperLoadTestingContext.Default)); + } + yield return Page.FromValues(items, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestRunsRequest(nextLink, _orderby, _search, _testId, _executionFrom, _executionTo, _status, _maxpagesize, _createdByTypes, _testIds, _context) : _client.CreateGetTestRunsRequest(_orderby, _search, _testId, _executionFrom, _executionTo, _status, _maxpagesize, _createdByTypes, _testIds, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRuns"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestRunsAsyncCollectionResultOfT.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestRunsAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..9c00d4a6e89c --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestRunsAsyncCollectionResultOfT.cs @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestRunClientGetTestRunsAsyncCollectionResultOfT : AsyncPageable + { + private readonly LoadTestRunClient _client; + private readonly string _orderby; + private readonly string _search; + private readonly string _testId; + private readonly DateTimeOffset? _executionFrom; + private readonly DateTimeOffset? _executionTo; + private readonly string _status; + private readonly int? _maxpagesize; + private readonly IEnumerable _createdByTypes; + private readonly IEnumerable _testIds; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestRunClientGetTestRunsAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LoadTestRunClient client used to send requests. + /// + /// 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. + /// Comma-separated list of test IDs. If you are using testIds, do not send a value for testId. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestRunClientGetTestRunsAsyncCollectionResultOfT(LoadTestRunClient client, string @orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, int? maxpagesize, IEnumerable createdByTypes, IEnumerable testIds, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _orderby = @orderby; + _search = search; + _testId = testId; + _executionFrom = executionFrom; + _executionTo = executionTo; + _status = status; + _maxpagesize = maxpagesize; + _createdByTypes = createdByTypes; + _testIds = testIds; + _context = context; + } + + /// Gets the pages of LoadTestRunClientGetTestRunsAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestRunClientGetTestRunsAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + PagedTestRun result = (PagedTestRun)response; + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestRunsRequest(nextLink, _orderby, _search, _testId, _executionFrom, _executionTo, _status, _maxpagesize, _createdByTypes, _testIds, _context) : _client.CreateGetTestRunsRequest(_orderby, _search, _testId, _executionFrom, _executionTo, _status, _maxpagesize, _createdByTypes, _testIds, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRuns"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestRunsCollectionResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestRunsCollectionResult.cs new file mode 100644 index 000000000000..c45f272453c0 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestRunsCollectionResult.cs @@ -0,0 +1,113 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestRunClientGetTestRunsCollectionResult : Pageable + { + private readonly LoadTestRunClient _client; + private readonly string _orderby; + private readonly string _search; + private readonly string _testId; + private readonly DateTimeOffset? _executionFrom; + private readonly DateTimeOffset? _executionTo; + private readonly string _status; + private readonly int? _maxpagesize; + private readonly IEnumerable _createdByTypes; + private readonly IEnumerable _testIds; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestRunClientGetTestRunsCollectionResult, which is used to iterate over the pages of a collection. + /// The LoadTestRunClient client used to send requests. + /// + /// 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. + /// Comma-separated list of test IDs. If you are using testIds, do not send a value for testId. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestRunClientGetTestRunsCollectionResult(LoadTestRunClient client, string @orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, int? maxpagesize, IEnumerable createdByTypes, IEnumerable testIds, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _orderby = @orderby; + _search = search; + _testId = testId; + _executionFrom = executionFrom; + _executionTo = executionTo; + _status = status; + _maxpagesize = maxpagesize; + _createdByTypes = createdByTypes; + _testIds = testIds; + _context = context; + } + + /// Gets the pages of LoadTestRunClientGetTestRunsCollectionResult as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestRunClientGetTestRunsCollectionResult as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + PagedTestRun result = (PagedTestRun)response; + List items = new List(); + foreach (var item in result.Value) + { + items.Add(ModelReaderWriter.Write(item, ModelSerializationExtensions.WireOptions, AzureDeveloperLoadTestingContext.Default)); + } + yield return Page.FromValues(items, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestRunsRequest(nextLink, _orderby, _search, _testId, _executionFrom, _executionTo, _status, _maxpagesize, _createdByTypes, _testIds, _context) : _client.CreateGetTestRunsRequest(_orderby, _search, _testId, _executionFrom, _executionTo, _status, _maxpagesize, _createdByTypes, _testIds, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRuns"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestRunsCollectionResultOfT.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestRunsCollectionResultOfT.cs new file mode 100644 index 000000000000..e4e74c9fe2ae --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CollectionResults/LoadTestRunClientGetTestRunsCollectionResultOfT.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; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal partial class LoadTestRunClientGetTestRunsCollectionResultOfT : Pageable + { + private readonly LoadTestRunClient _client; + private readonly string _orderby; + private readonly string _search; + private readonly string _testId; + private readonly DateTimeOffset? _executionFrom; + private readonly DateTimeOffset? _executionTo; + private readonly string _status; + private readonly int? _maxpagesize; + private readonly IEnumerable _createdByTypes; + private readonly IEnumerable _testIds; + private readonly RequestContext _context; + + /// Initializes a new instance of LoadTestRunClientGetTestRunsCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LoadTestRunClient client used to send requests. + /// + /// 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. + /// Comma-separated list of test IDs. If you are using testIds, do not send a value for testId. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public LoadTestRunClientGetTestRunsCollectionResultOfT(LoadTestRunClient client, string @orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, int? maxpagesize, IEnumerable createdByTypes, IEnumerable testIds, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _orderby = @orderby; + _search = search; + _testId = testId; + _executionFrom = executionFrom; + _executionTo = executionTo; + _status = status; + _maxpagesize = maxpagesize; + _createdByTypes = createdByTypes; + _testIds = testIds; + _context = context; + } + + /// Gets the pages of LoadTestRunClientGetTestRunsCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LoadTestRunClientGetTestRunsCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + PagedTestRun result = (PagedTestRun)response; + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetTestRunsRequest(nextLink, _orderby, _search, _testId, _executionFrom, _executionTo, _status, _maxpagesize, _createdByTypes, _testIds, _context) : _client.CreateGetTestRunsRequest(_orderby, _search, _testId, _executionFrom, _executionTo, _status, _maxpagesize, _createdByTypes, _testIds, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRuns"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CreatedByType.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CreatedByType.cs index 404520f2bea4..fee5a7e34287 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CreatedByType.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/CreatedByType.cs @@ -14,44 +14,67 @@ namespace Azure.Developer.LoadTesting public readonly partial struct CreatedByType : IEquatable { private readonly string _value; + /// Entity was created by a user. + private const string UserValue = "User"; + /// Entity was created by a scheduled trigger. + private const string ScheduledTriggerValue = "ScheduledTrigger"; + /// Entity was created by Azure DevOps pipelines. + private const string AzurePipelinesValue = "AzurePipelines"; + /// Entity was created by GitHub Workflows. + private const string GitHubWorkflowsValue = "GitHubWorkflows"; /// Initializes a new instance of . + /// The value. /// is null. public CreatedByType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string UserValue = "User"; - private const string ScheduledTriggerValue = "ScheduledTrigger"; - private const string AzurePipelinesValue = "AzurePipelines"; - private const string GitHubWorkflowsValue = "GitHubWorkflows"; + _value = value; + } /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(CreatedByType left, CreatedByType right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(CreatedByType left, CreatedByType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator CreatedByType(string value) => new CreatedByType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator CreatedByType?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DailyRecurrence.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DailyRecurrence.Serialization.cs index b966a79a0917..37f63963cbef 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DailyRecurrence.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DailyRecurrence.Serialization.cs @@ -9,14 +9,19 @@ 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 + /// Recurrence model when frequency is set as Daily. + public partial class DailyRecurrence : LoadTestingRecurrence, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DailyRecurrence() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,76 +33,81 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO /// 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; + string 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) + /// The JSON reader. + /// The client options for reading and writing models. + DailyRecurrence IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DailyRecurrence)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override LoadTestingRecurrence JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DailyRecurrence DeserializeDailyRecurrence(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + int interval = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("interval"u8)) + if (prop.NameEquals("frequency"u8)) { - interval = property.Value.GetInt32(); + frequency = new Frequency(prop.Value.GetString()); continue; } - if (property.NameEquals("frequency"u8)) + if (prop.NameEquals("recurrenceEnd"u8)) { - frequency = new Frequency(property.Value.GetString()); - continue; - } - if (property.NameEquals("recurrenceEnd"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(property.Value, options); + recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(prop.Value, options); + continue; + } + if (prop.NameEquals("interval"u8)) + { + interval = prop.Value.GetInt32(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new DailyRecurrence(frequency, recurrenceEnd, serializedAdditionalRawData, interval); + return new DailyRecurrence(frequency, recurrenceEnd, additionalBinaryDataProperties, interval); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -107,15 +117,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opt } } - DailyRecurrence IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DailyRecurrence IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DailyRecurrence)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override LoadTestingRecurrence PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDailyRecurrence(document.RootElement, options); } default: @@ -123,22 +138,7 @@ DailyRecurrence IPersistableModel.Create(BinaryData data, Model } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DailyRecurrence.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DailyRecurrence.cs index a2228904bed1..190c011608f2 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DailyRecurrence.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DailyRecurrence.cs @@ -15,27 +15,21 @@ public partial class DailyRecurrence : LoadTestingRecurrence { /// 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) + public DailyRecurrence(int interval) : base(Frequency.Daily) { - 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. + /// 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) + internal DailyRecurrence(Frequency frequency, RecurrenceEnd recurrenceEnd, IDictionary additionalBinaryDataProperties, int interval) : base(frequency, recurrenceEnd, additionalBinaryDataProperties) { 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionFilter.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionFilter.Serialization.cs index e9ae3ad7af6e..20196d5d0259 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionFilter.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionFilter.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Dimension name and values to filter. + public partial class DimensionFilter : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO /// 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; + string 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); @@ -43,21 +42,26 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("values"u8); writer.WriteStartArray(); - foreach (var item in Values) + foreach (string item in Values) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -66,64 +70,77 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DimensionFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DimensionFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DimensionFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DimensionFilter DeserializeDimensionFilter(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("values"u8)) + if (prop.NameEquals("values"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { - array.Add(item.GetString()); + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } } values = array; continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new DimensionFilter(name, values ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new DimensionFilter(name, values ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -133,15 +150,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opt } } - DimensionFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DimensionFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DimensionFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDimensionFilter(document.RootElement, options); } default: @@ -149,22 +171,7 @@ DimensionFilter IPersistableModel.Create(BinaryData data, Model } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionFilter.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionFilter.cs index 51ae24c5f29d..6126c311fb7d 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionFilter.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionFilter.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public DimensionFilter() @@ -54,16 +25,17 @@ public DimensionFilter() /// 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) + /// Keeps track of any properties unknown to the library. + internal DimensionFilter(string name, IList values, IDictionary additionalBinaryDataProperties) { Name = name; Values = values; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The dimension name. public string Name { get; set; } + /// The dimension values. Maximum values can be 20. public IList Values { get; } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionValue.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionValue.Serialization.cs index ca1794a05c93..b72322d51e9f 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionValue.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionValue.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Represents a metric dimension value. + public partial class DimensionValue : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp /// 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; + string 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); @@ -44,15 +43,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("value"u8); writer.WriteStringValue(Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,55 +60,61 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DimensionValue IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DimensionValue IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DimensionValue JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DimensionValue DeserializeDimensionValue(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { - value = property.Value.GetString(); + value = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new DimensionValue(name, value, serializedAdditionalRawData); + return new DimensionValue(name, value, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -119,15 +124,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opti } } - DimensionValue IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DimensionValue IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DimensionValue PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDimensionValue(document.RootElement, options); } default: @@ -135,22 +145,7 @@ DimensionValue IPersistableModel.Create(BinaryData data, ModelRe } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionValue.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionValue.cs index 84f36f89f44e..57740de464a0 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionValue.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionValue.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal DimensionValue() @@ -53,16 +24,17 @@ 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) + /// Keeps track of any properties unknown to the library. + internal DimensionValue(string name, string value, IDictionary additionalBinaryDataProperties) { Name = name; Value = value; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The name of the dimension. public string Name { get; } + /// The value of the dimension. public string Value { get; } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionValueList.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionValueList.Serialization.cs new file mode 100644 index 000000000000..d0e0c750225e --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionValueList.Serialization.cs @@ -0,0 +1,200 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; + +namespace Azure.Developer.LoadTesting +{ + /// Metrics dimension values. + internal partial class DimensionValueList : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + 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) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DimensionValueList)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (string item in Value) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + DimensionValueList IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DimensionValueList JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DimensionValueList)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDimensionValueList(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DimensionValueList DeserializeDimensionValueList(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("value"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new DimensionValueList(name, value ?? new ChangeTrackingList(), nextLink, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureDeveloperLoadTestingContext.Default); + default: + throw new FormatException($"The model {nameof(DimensionValueList)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + DimensionValueList IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DimensionValueList PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeDimensionValueList(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DimensionValueList)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator DimensionValueList(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDimensionValueList(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionValueList.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionValueList.cs new file mode 100644 index 000000000000..cf056831ba95 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/DimensionValueList.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + /// Metrics dimension values. + internal partial class DimensionValueList + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal DimensionValueList() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The dimension name. + /// The dimension value. + /// Link for the next set of values in case of paginated results, if applicable. + /// Keeps track of any properties unknown to the library. + internal DimensionValueList(string name, IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Name = name; + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The dimension name. + public string Name { get; } + + /// The dimension value. + public IList Value { get; } + + /// Link for the next set of values in case of paginated results, if applicable. + public Uri NextLink { get; } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ErrorDetails.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ErrorDetails.Serialization.cs index 891860d535c5..1ea4fe2e474e 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ErrorDetails.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ErrorDetails.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Error details if there is any failure in load test run. + public partial class ErrorDetails : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti /// 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; + string 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(Code)) { writer.WritePropertyName("code"u8); @@ -57,23 +56,28 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit continue; } writer.WriteStartArray(); - foreach (var item0 in item.Value) + foreach (string item0 in item.Value) { + if (item0 == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item0); } writer.WriteEndArray(); } writer.WriteEndObject(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -82,22 +86,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ErrorDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ErrorDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ErrorDetails JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ErrorDetails DeserializeErrorDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -105,41 +114,47 @@ internal static ErrorDetails DeserializeErrorDetails(JsonElement element, ModelR string code = default; string message = default; IReadOnlyDictionary> properties = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("code"u8)) + if (prop.NameEquals("code"u8)) { - code = property.Value.GetString(); + code = prop.Value.GetString(); continue; } - if (property.NameEquals("message"u8)) + if (prop.NameEquals("message"u8)) { - message = property.Value.GetString(); + message = prop.Value.GetString(); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary> dictionary = new Dictionary>(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - if (property0.Value.ValueKind == JsonValueKind.Null) + if (prop0.Value.ValueKind == JsonValueKind.Null) { - dictionary.Add(property0.Name, null); + dictionary.Add(prop0.Name, null); } else { List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) + foreach (var item in prop0.Value.EnumerateArray()) { - array.Add(item.GetString()); + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } } - dictionary.Add(property0.Name, array); + dictionary.Add(prop0.Name, array); } } properties = dictionary; @@ -147,17 +162,19 @@ internal static ErrorDetails DeserializeErrorDetails(JsonElement element, ModelR } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new ErrorDetails(code, message, properties ?? new ChangeTrackingDictionary>(), serializedAdditionalRawData); + return new ErrorDetails(code, message, properties ?? new ChangeTrackingDictionary>(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -167,15 +184,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions option } } - ErrorDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + ErrorDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ErrorDetails PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeErrorDetails(document.RootElement, options); } default: @@ -183,22 +205,7 @@ ErrorDetails IPersistableModel.Create(BinaryData data, ModelReader } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ErrorDetails.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ErrorDetails.cs index a9d911d79fa6..3200e02d4f71 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ErrorDetails.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ErrorDetails.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal ErrorDetails() @@ -55,19 +26,21 @@ internal ErrorDetails() /// Error code if there is any failure in load test run. /// Error details in case test run was not successfully run. /// A dictionary for storing additional error information for better context. Each key is a property name (e.g., "Description", "Resolution", "Category", "Region"), and its value is an array of strings with relevant details. - /// Keeps track of any properties unknown to the library. - internal ErrorDetails(string code, string message, IReadOnlyDictionary> properties, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ErrorDetails(string code, string message, IReadOnlyDictionary> properties, IDictionary additionalBinaryDataProperties) { Code = code; Message = message; Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Error code if there is any failure in load test run. public string Code { get; } + /// Error details in case test run was not successfully run. public string Message { get; } + /// A dictionary for storing additional error information for better context. Each key is a property name (e.g., "Description", "Resolution", "Category", "Region"), and its value is an array of strings with relevant details. public IReadOnlyDictionary> Properties { get; } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FileValidationStatus.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FileValidationStatus.cs index 93393256bc43..5240f914c7e5 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FileValidationStatus.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FileValidationStatus.cs @@ -14,47 +14,72 @@ namespace Azure.Developer.LoadTesting public readonly partial struct FileValidationStatus : IEquatable { private readonly string _value; + /// File is not validated. + private const string NotValidatedValue = "NOT_VALIDATED"; + /// File is validated. + private const string ValidationSuccessValue = "VALIDATION_SUCCESS"; + /// File validation is failed. + private const string ValidationFailureValue = "VALIDATION_FAILURE"; + /// File validation is in progress. + private const string ValidationInitiatedValue = "VALIDATION_INITIATED"; + /// Validation is not required. + private const string ValidationNotRequiredValue = "VALIDATION_NOT_REQUIRED"; /// Initializes a new instance of . + /// The value. /// is null. public FileValidationStatus(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, 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"; + _value = value; + } /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(FileValidationStatus left, FileValidationStatus right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(FileValidationStatus left, FileValidationStatus right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator FileValidationStatus(string value) => new FileValidationStatus(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator FileValidationStatus?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Frequency.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Frequency.cs index 2c71e6f486c7..157781f1c8cf 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Frequency.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Frequency.cs @@ -14,50 +14,77 @@ namespace Azure.Developer.LoadTesting 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)); - } - + /// Recurrence defined by a cron expression. private const string CronValue = "Cron"; + /// Recurrence defined on an hourly basis, as specified by HourlyRecurrence. private const string HourlyValue = "Hourly"; + /// Recurrence defined on a daily basis, as specified by DailyRecurrence. private const string DailyValue = "Daily"; + /// Recurrence defined on a weekly basis, as specified by WeeklyRecurrence. private const string WeeklyValue = "Weekly"; + /// Recurrence defined monthly on specific days, as specified by MonthlyRecurrenceByWeekDays. private const string MonthlyByDaysValue = "MonthlyByDays"; + /// Recurrence defined monthly on specific dates, as specified by MonthlyRecurrenceByDates. private const string MonthlyByDatesValue = "MonthlyByDates"; + /// Initializes a new instance of . + /// The value. + /// is null. + public Frequency(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(Frequency left, Frequency right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(Frequency left, Frequency right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator Frequency(string value) => new Frequency(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator Frequency?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionResourceConfiguration.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionResourceConfiguration.Serialization.cs index 3533e8234c0d..8b2f65b0f588 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionResourceConfiguration.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionResourceConfiguration.Serialization.cs @@ -9,14 +9,19 @@ 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 + /// Resource configuration instance for a Flex Consumption based Azure Function App. + public partial class FunctionFlexConsumptionResourceConfiguration : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal FunctionFlexConsumptionResourceConfiguration() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +33,11 @@ void IJsonModel.Write(Utf8JsonWrit /// 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; + string 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)) @@ -41,15 +45,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("httpConcurrency"u8); writer.WriteNumberValue(HttpConcurrency.Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -58,59 +62,65 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - FunctionFlexConsumptionResourceConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + FunctionFlexConsumptionResourceConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual FunctionFlexConsumptionResourceConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static FunctionFlexConsumptionResourceConfiguration DeserializeFunctionFlexConsumptionResourceConfiguration(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("instanceMemoryMB"u8)) + if (prop.NameEquals("instanceMemoryMB"u8)) { - instanceMemoryMB = property.Value.GetInt64(); + instanceMemoryMB = prop.Value.GetInt64(); continue; } - if (property.NameEquals("httpConcurrency"u8)) + if (prop.NameEquals("httpConcurrency"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - httpConcurrency = property.Value.GetInt64(); + httpConcurrency = prop.Value.GetInt64(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new FunctionFlexConsumptionResourceConfiguration(instanceMemoryMB, httpConcurrency, serializedAdditionalRawData); + return new FunctionFlexConsumptionResourceConfiguration(instanceMemoryMB, httpConcurrency, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -120,15 +130,20 @@ BinaryData IPersistableModel.Write } } - FunctionFlexConsumptionResourceConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + FunctionFlexConsumptionResourceConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual FunctionFlexConsumptionResourceConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeFunctionFlexConsumptionResourceConfiguration(document.RootElement, options); } default: @@ -136,22 +151,7 @@ FunctionFlexConsumptionResourceConfiguration IPersistableModel The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionResourceConfiguration.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionResourceConfiguration.cs index 78c4e07ce0de..7a6a4f8d5168 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionResourceConfiguration.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionResourceConfiguration.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// Memory size of the instance. Supported values are 2048, 4096. @@ -55,21 +26,17 @@ public FunctionFlexConsumptionResourceConfiguration(long 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) + /// Keeps track of any properties unknown to the library. + internal FunctionFlexConsumptionResourceConfiguration(long instanceMemoryMB, long? httpConcurrency, IDictionary additionalBinaryDataProperties) { InstanceMemoryMB = instanceMemoryMB; HttpConcurrency = httpConcurrency; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal FunctionFlexConsumptionResourceConfiguration() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionTargetResourceConfigurations.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionTargetResourceConfigurations.Serialization.cs index 033ea7cf8466..948bb21989a4 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionTargetResourceConfigurations.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionTargetResourceConfigurations.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Configurations for a Function App using Flex Consumption Plan. + public partial class FunctionFlexConsumptionTargetResourceConfigurations : TargetResourceConfigurations, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8J /// 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; + string 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)) { @@ -48,64 +47,70 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - FunctionFlexConsumptionTargetResourceConfigurations IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + FunctionFlexConsumptionTargetResourceConfigurations IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (FunctionFlexConsumptionTargetResourceConfigurations)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TargetResourceConfigurations JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static FunctionFlexConsumptionTargetResourceConfigurations DeserializeFunctionFlexConsumptionTargetResourceConfigurations(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary configurations = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("configurations"u8)) + if (prop.NameEquals("kind"u8)) + { + kind = new ResourceKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("configurations"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, FunctionFlexConsumptionResourceConfiguration.DeserializeFunctionFlexConsumptionResourceConfiguration(property0.Value, options)); + dictionary.Add(prop0.Name, FunctionFlexConsumptionResourceConfiguration.DeserializeFunctionFlexConsumptionResourceConfiguration(prop0.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())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new FunctionFlexConsumptionTargetResourceConfigurations(kind, serializedAdditionalRawData, configurations ?? new ChangeTrackingDictionary()); + return new FunctionFlexConsumptionTargetResourceConfigurations(kind, additionalBinaryDataProperties, configurations ?? new ChangeTrackingDictionary()); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -115,15 +120,20 @@ BinaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + FunctionFlexConsumptionTargetResourceConfigurations IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (FunctionFlexConsumptionTargetResourceConfigurations)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override TargetResourceConfigurations PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeFunctionFlexConsumptionTargetResourceConfigurations(document.RootElement, options); } default: @@ -131,22 +141,7 @@ FunctionFlexConsumptionTargetResourceConfigurations IPersistableModel The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionTargetResourceConfigurations.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionTargetResourceConfigurations.cs index 3325be60e099..9216b52c907e 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionTargetResourceConfigurations.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/FunctionFlexConsumptionTargetResourceConfigurations.cs @@ -14,17 +14,16 @@ namespace Azure.Developer.LoadTesting public partial class FunctionFlexConsumptionTargetResourceConfigurations : TargetResourceConfigurations { /// Initializes a new instance of . - public FunctionFlexConsumptionTargetResourceConfigurations() + public FunctionFlexConsumptionTargetResourceConfigurations() : base(ResourceKind.FunctionsFlexConsumption) { - 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. + /// 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) + internal FunctionFlexConsumptionTargetResourceConfigurations(ResourceKind kind, IDictionary additionalBinaryDataProperties, IDictionary configurations) : base(kind, additionalBinaryDataProperties) { Configurations = configurations; } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/HourlyRecurrence.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/HourlyRecurrence.Serialization.cs index 0e7e139ce930..5acb0245bc65 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/HourlyRecurrence.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/HourlyRecurrence.Serialization.cs @@ -9,14 +9,19 @@ 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 + /// Recurrence model when frequency is set as Hourly. + public partial class HourlyRecurrence : LoadTestingRecurrence, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal HourlyRecurrence() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,76 +33,81 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter /// 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; + string 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) + /// The JSON reader. + /// The client options for reading and writing models. + HourlyRecurrence IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (HourlyRecurrence)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override LoadTestingRecurrence JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static HourlyRecurrence DeserializeHourlyRecurrence(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + int interval = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("interval"u8)) + if (prop.NameEquals("frequency"u8)) { - interval = property.Value.GetInt32(); + frequency = new Frequency(prop.Value.GetString()); continue; } - if (property.NameEquals("frequency"u8)) + if (prop.NameEquals("recurrenceEnd"u8)) { - frequency = new Frequency(property.Value.GetString()); - continue; - } - if (property.NameEquals("recurrenceEnd"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(property.Value, options); + recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(prop.Value, options); + continue; + } + if (prop.NameEquals("interval"u8)) + { + interval = prop.Value.GetInt32(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new HourlyRecurrence(frequency, recurrenceEnd, serializedAdditionalRawData, interval); + return new HourlyRecurrence(frequency, recurrenceEnd, additionalBinaryDataProperties, interval); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -107,15 +117,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions op } } - HourlyRecurrence IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + HourlyRecurrence IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (HourlyRecurrence)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override LoadTestingRecurrence PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeHourlyRecurrence(document.RootElement, options); } default: @@ -123,22 +138,7 @@ HourlyRecurrence IPersistableModel.Create(BinaryData data, Mod } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/HourlyRecurrence.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/HourlyRecurrence.cs index 74e4d84395b5..a3d8e5bf9284 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/HourlyRecurrence.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/HourlyRecurrence.cs @@ -15,27 +15,21 @@ public partial class HourlyRecurrence : LoadTestingRecurrence { /// 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) + public HourlyRecurrence(int interval) : base(Frequency.Hourly) { - 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. + /// 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) + internal HourlyRecurrence(Frequency frequency, RecurrenceEnd recurrenceEnd, IDictionary additionalBinaryDataProperties, int interval) : base(frequency, recurrenceEnd, additionalBinaryDataProperties) { 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/Argument.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/Argument.cs index 946929b236ff..15f00ace8b91 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/Argument.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/Argument.cs @@ -11,8 +11,10 @@ namespace Azure.Developer.LoadTesting { - internal static class Argument + internal static partial class Argument { + /// The value. + /// The name. public static void AssertNotNull(T value, string name) { if (value is null) @@ -21,8 +23,10 @@ public static void AssertNotNull(T value, string name) } } + /// The value. + /// The name. public static void AssertNotNull(T? value, string name) - where T : struct + where T : struct { if (!value.HasValue) { @@ -30,6 +34,8 @@ public static void AssertNotNull(T? value, string name) } } + /// The value. + /// The name. public static void AssertNotNullOrEmpty(IEnumerable value, string name) { if (value is null) @@ -51,6 +57,8 @@ public static void AssertNotNullOrEmpty(IEnumerable value, string name) } } + /// The value. + /// The name. public static void AssertNotNullOrEmpty(string value, string name) { if (value is null) @@ -62,68 +70,5 @@ public static void AssertNotNullOrEmpty(string value, string name) 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/CancellationTokenExtensions.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/CancellationTokenExtensions.cs new file mode 100644 index 000000000000..8435c0819b74 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/CancellationTokenExtensions.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Threading; +using Azure; + +namespace Azure.Developer.LoadTesting +{ + internal static partial class CancellationTokenExtensions + { + public static RequestContext ToRequestContext(this CancellationToken cancellationToken) => cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingDictionary.cs index 9a5316eba10d..c550cf7320fb 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingDictionary.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -11,7 +11,8 @@ namespace Azure.Developer.LoadTesting { - internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + internal partial class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary + where TKey : notnull { private IDictionary _innerDictionary; @@ -19,6 +20,7 @@ public ChangeTrackingDictionary() { } + /// The inner dictionary. public ChangeTrackingDictionary(IDictionary dictionary) { if (dictionary == null) @@ -28,6 +30,7 @@ public ChangeTrackingDictionary(IDictionary dictionary) _innerDictionary = new Dictionary(dictionary); } + /// The inner dictionary. public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) { if (dictionary == null) @@ -41,16 +44,22 @@ public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) } } + /// Gets the IsUndefined. public bool IsUndefined => _innerDictionary == null; + /// Gets the Count. public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + /// Gets the IsReadOnly. public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + /// Gets the Keys. public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + /// Gets the Values. public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + /// Gets or sets the value associated with the specified key. public TValue this[TKey key] { get @@ -67,8 +76,10 @@ public TValue this[TKey key] } } + /// Gets the Keys. IEnumerable IReadOnlyDictionary.Keys => Keys; + /// Gets the Values. IEnumerable IReadOnlyDictionary.Values => Values; public IEnumerator> GetEnumerator() @@ -89,6 +100,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetEnumerator(); } + /// The item to add. public void Add(KeyValuePair item) { EnsureDictionary().Add(item); @@ -99,6 +111,7 @@ public void Clear() EnsureDictionary().Clear(); } + /// The item to search for. public bool Contains(KeyValuePair item) { if (IsUndefined) @@ -108,6 +121,8 @@ public bool Contains(KeyValuePair item) return EnsureDictionary().Contains(item); } + /// The array to copy. + /// The index. public void CopyTo(KeyValuePair[] array, int index) { if (IsUndefined) @@ -117,6 +132,7 @@ public void CopyTo(KeyValuePair[] array, int index) EnsureDictionary().CopyTo(array, index); } + /// The item to remove. public bool Remove(KeyValuePair item) { if (IsUndefined) @@ -126,11 +142,14 @@ public bool Remove(KeyValuePair item) return EnsureDictionary().Remove(item); } + /// The key. + /// The value to add. public void Add(TKey key, TValue value) { EnsureDictionary().Add(key, value); } + /// The key to search for. public bool ContainsKey(TKey key) { if (IsUndefined) @@ -140,6 +159,7 @@ public bool ContainsKey(TKey key) return EnsureDictionary().ContainsKey(key); } + /// The key. public bool Remove(TKey key) { if (IsUndefined) @@ -149,6 +169,8 @@ public bool Remove(TKey key) return EnsureDictionary().Remove(key); } + /// The key to search for. + /// The value. public bool TryGetValue(TKey key, out TValue value) { if (IsUndefined) diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingList.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingList.cs index 5de833439355..76483e2006f1 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingList.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingList.cs @@ -12,7 +12,7 @@ namespace Azure.Developer.LoadTesting { - internal class ChangeTrackingList : IList, IReadOnlyList + internal partial class ChangeTrackingList : IList, IReadOnlyList { private IList _innerList; @@ -20,6 +20,7 @@ public ChangeTrackingList() { } + /// The inner list. public ChangeTrackingList(IList innerList) { if (innerList != null) @@ -28,6 +29,7 @@ public ChangeTrackingList(IList innerList) } } + /// The inner list. public ChangeTrackingList(IReadOnlyList innerList) { if (innerList != null) @@ -36,12 +38,16 @@ public ChangeTrackingList(IReadOnlyList innerList) } } + /// Gets the IsUndefined. public bool IsUndefined => _innerList == null; + /// Gets the Count. public int Count => IsUndefined ? 0 : EnsureList().Count; + /// Gets the IsReadOnly. public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + /// Gets or sets the value associated with the specified key. public T this[int index] { get @@ -85,6 +91,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetEnumerator(); } + /// The item to add. public void Add(T item) { EnsureList().Add(item); @@ -95,6 +102,7 @@ public void Clear() EnsureList().Clear(); } + /// The item. public bool Contains(T item) { if (IsUndefined) @@ -104,6 +112,8 @@ public bool Contains(T item) return EnsureList().Contains(item); } + /// The array to copy to. + /// The array index. public void CopyTo(T[] array, int arrayIndex) { if (IsUndefined) @@ -113,6 +123,7 @@ public void CopyTo(T[] array, int arrayIndex) EnsureList().CopyTo(array, arrayIndex); } + /// The item. public bool Remove(T item) { if (IsUndefined) @@ -122,6 +133,7 @@ public bool Remove(T item) return EnsureList().Remove(item); } + /// The item. public int IndexOf(T item) { if (IsUndefined) @@ -131,11 +143,14 @@ public int IndexOf(T item) return EnsureList().IndexOf(item); } + /// The inner list. + /// The item. public void Insert(int index, T item) { EnsureList().Insert(index, item); } + /// The inner list. public void RemoveAt(int index) { if (IsUndefined) diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..bad06110c6f4 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/ClientPipelineExtensions.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Developer.LoadTesting +{ + internal static partial class ClientPipelineExtensions + { + public static async ValueTask ProcessMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse(); + await pipeline.SendAsync(message, userCancellationToken).ConfigureAwait(false); + + if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static Response ProcessMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse(); + pipeline.Send(message, userCancellationToken); + + if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static async ValueTask> ProcessHeadAsBoolMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = await pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + + public static Response ProcessHeadAsBoolMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = pipeline.ProcessMessage(message, context); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/CodeGenMemberAttribute.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..34e2c20edeed --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/CodeGenMemberAttribute.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.Developer.LoadTesting +{ + [AttributeUsage((AttributeTargets.Property | AttributeTargets.Field))] + internal partial class CodeGenMemberAttribute : CodeGenTypeAttribute + { + /// The original name of the member. + public CodeGenMemberAttribute(string originalName) : base(originalName) + { + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/CodeGenSerializationAttribute.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..1c2d9d145bbc --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/CodeGenSerializationAttribute.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.Developer.LoadTesting +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Struct), AllowMultiple = true, Inherited = true)] + internal partial class CodeGenSerializationAttribute : Attribute + { + /// The property name which these hooks apply to. + public CodeGenSerializationAttribute(string propertyName) + { + PropertyName = propertyName; + } + + /// The property name which these hooks apply to. + /// The serialization name of the property. + public CodeGenSerializationAttribute(string propertyName, string serializationName) + { + PropertyName = propertyName; + SerializationName = serializationName; + } + + /// Gets or sets the property name which these hooks should apply to. + public string PropertyName { get; } + + /// Gets or sets the serialization name of the property. + public string SerializationName { get; set; } + + /// + /// Gets or sets the method name to use when serializing the property value (property name excluded). + /// The signature of the serialization hook method must be or compatible with when invoking: private void SerializeHook(Utf8JsonWriter writer); + /// + public string SerializationValueHook { get; set; } + + /// + /// Gets or sets the method name to use when deserializing the property value from the JSON. + /// private static void DeserializationHook(JsonProperty property, ref TypeOfTheProperty propertyValue); // if the property is required + /// private static void DeserializationHook(JsonProperty property, ref Optional<TypeOfTheProperty> propertyValue); // if the property is optional + /// + public string DeserializationValueHook { get; set; } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/CodeGenSuppressAttribute.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..aad0f5dace60 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/CodeGenSuppressAttribute.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.Developer.LoadTesting +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct), AllowMultiple = true)] + internal partial class CodeGenSuppressAttribute : Attribute + { + /// The member to suppress. + /// The types of the parameters of the member. + public CodeGenSuppressAttribute(string member, params Type[] parameters) + { + Member = member; + Parameters = parameters; + } + + /// Gets the Member. + public string Member { get; } + + /// Gets the Parameters. + public Type[] Parameters { get; } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/CodeGenTypeAttribute.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..30e9d035628e --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/CodeGenTypeAttribute.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.Developer.LoadTesting +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct))] + internal partial class CodeGenTypeAttribute : Attribute + { + /// The original name of the type. + public CodeGenTypeAttribute(string originalName) + { + OriginalName = originalName; + } + + /// Gets the OriginalName. + public string OriginalName { get; } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/ErrorResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..dd5bf5f75601 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/ErrorResult.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure; + +namespace Azure.Developer.LoadTesting +{ + internal partial class ErrorResult : Response + { + private readonly Response _response; + private readonly RequestFailedException _exception; + + public ErrorResult(Response response, RequestFailedException exception) + { + _response = response; + _exception = exception; + } + + /// Gets the Value. + public override T Value => throw _exception; + + /// + public override Response GetRawResponse() + { + return _response; + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/ModelSerializationExtensions.cs index 9b438c4d8dd1..d4aa16649eef 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/ModelSerializationExtensions.cs @@ -11,18 +11,16 @@ 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 partial class ModelSerializationExtensions { - internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); - internal static readonly ModelReaderWriterOptions WireV3Options = new ModelReaderWriterOptions("W|v3"); - internal static readonly ModelReaderWriterOptions JsonV3Options = new ModelReaderWriterOptions("J|v3"); - internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions + { + MaxDepth = 256 + }; public static object GetObject(this JsonElement element) { @@ -48,14 +46,14 @@ public static object GetObject(this JsonElement element) case JsonValueKind.Null: return null; case JsonValueKind.Object: - var dictionary = new Dictionary(); + Dictionary 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(); + List list = new List(); foreach (var item in element.EnumerateArray()) { list.Add(item.GetObject()); @@ -93,7 +91,7 @@ public static char GetChar(this JsonElement element) { if (element.ValueKind == JsonValueKind.String) { - var text = element.GetString(); + string text = element.GetString(); if (text == null || text.Length != 1) { throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); @@ -107,14 +105,14 @@ public static char GetChar(this JsonElement element) } [Conditional("DEBUG")] - public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + 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"); + 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(); + string 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}'."); @@ -181,9 +179,6 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, T value, Mode case IJsonModel jsonModel: jsonModel.Write(writer, options ?? WireOptions); break; - case IUtf8JsonSerializable serializable: - serializable.Write(writer); - break; case byte[] bytes: writer.WriteBase64StringValue(bytes); break; @@ -259,151 +254,5 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, object value, Mo { writer.WriteObjectValue(value, options); } - - internal static bool IsSentinelValue(BinaryData value) - { - ReadOnlySpan sentinelSpan = SentinelValue.ToMemory().Span; - ReadOnlySpan valueSpan = value.ToMemory().Span; - return sentinelSpan.SequenceEqual(valueSpan); - } - - 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/Optional.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/Optional.cs index 248e10182762..3e07f66eb631 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/Optional.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/Optional.cs @@ -10,7 +10,7 @@ namespace Azure.Developer.LoadTesting { - internal static class Optional + internal static partial class Optional { public static bool IsCollectionDefined(IEnumerable collection) { @@ -28,7 +28,7 @@ public static bool IsCollectionDefined(IReadOnlyDictionary(T? value) - where T : struct + where T : struct { return value.HasValue; } @@ -38,14 +38,14 @@ public static bool IsDefined(object value) return value != null; } - public static bool IsDefined(JsonElement value) + public static bool IsDefined(string value) { - return value.ValueKind != JsonValueKind.Undefined; + return value != null; } - public static bool IsDefined(string value) + public static bool IsDefined(JsonElement value) { - return value != null; + return value.ValueKind != JsonValueKind.Undefined; } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..8379f48b8078 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/RawRequestUriBuilderExtensions.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + internal static partial class RawRequestUriBuilderExtensions + { + public static void AppendQueryDelimited(this RawRequestUriBuilder builder, string name, IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) + { + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + builder.AppendQuery(name, string.Join(delimiter, stringValues), escape); + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/RequestContextExtensions.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..cd5b95b568c2 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/RequestContextExtensions.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure; + +namespace Azure.Developer.LoadTesting +{ + internal static partial class RequestContextExtensions + { + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + public static ValueTuple Parse(this RequestContext context) + { + if (context == null) + { + return (CancellationToken.None, ErrorOptions.Default); + } + return (context.CancellationToken, context.ErrorOptions); + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/SerializationFormat.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..33c84d1fdef8 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/SerializationFormat.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.Developer.LoadTesting +{ + internal enum SerializationFormat + { + /// The default serialization format. + Default = 0, + /// The RFC1123 date time format. + DateTime_RFC1123 = 1, + /// The RFC3339 date time format. + DateTime_RFC3339 = 2, + /// The RFC7231 date time format. + DateTime_RFC7231 = 3, + /// The ISO8601 date time format. + DateTime_ISO8601 = 4, + /// The Unix date time format. + DateTime_Unix = 5, + /// The ISO8601 date format. + Date_ISO8601 = 6, + /// The ISO8601 duration format. + Duration_ISO8601 = 7, + /// The constant duration format. + Duration_Constant = 8, + /// The seconds duration format. + Duration_Seconds = 9, + /// The seconds duration format with float precision. + Duration_Seconds_Float = 10, + /// The seconds duration format with double precision. + Duration_Seconds_Double = 11, + /// The milliseconds duration format. + Duration_Milliseconds = 12, + /// The milliseconds duration format with float precision. + Duration_Milliseconds_Float = 13, + /// The milliseconds duration format with double precision. + Duration_Milliseconds_Double = 14, + /// The ISO8601 time format. + Time_ISO8601 = 15, + /// The Base64Url bytes format. + Bytes_Base64Url = 16, + /// The Base64 bytes format. + Bytes_Base64 = 17 + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/TypeFormatters.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..87b0f01b7d82 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/TypeFormatters.cs @@ -0,0 +1,180 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; + +namespace Azure.Developer.LoadTesting +{ + internal static partial 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}. Generated clients require 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" => System.Xml.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" => System.Xml.XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ToFormatSpecifier(SerializationFormat format) => format switch + { + SerializationFormat.DateTime_RFC1123 => "R", + SerializationFormat.DateTime_RFC3339 => "O", + SerializationFormat.DateTime_RFC7231 => "R", + SerializationFormat.DateTime_ISO8601 => "O", + SerializationFormat.Date_ISO8601 => "D", + SerializationFormat.DateTime_Unix => "U", + SerializationFormat.Bytes_Base64Url => "U", + SerializationFormat.Bytes_Base64 => "D", + SerializationFormat.Duration_ISO8601 => "P", + SerializationFormat.Duration_Constant => "c", + SerializationFormat.Duration_Seconds => "%s", + SerializationFormat.Duration_Seconds_Float => "s\\.FFF", + SerializationFormat.Duration_Seconds_Double => "s\\.FFFFFF", + SerializationFormat.Time_ISO8601 => "T", + _ => null + }; + + public static string ConvertToString(object value, SerializationFormat format = SerializationFormat.Default) + { + string formatSpecifier = ToFormatSpecifier(format); + + return 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 formatSpecifier != null => ToString(b0, formatSpecifier), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when formatSpecifier != null => ToString(dateTime, formatSpecifier), + TimeSpan timeSpan when format == SerializationFormat.Duration_Seconds => Convert.ToInt32(timeSpan.TotalSeconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan0 when format == SerializationFormat.Duration_Seconds_Float || format == SerializationFormat.Duration_Seconds_Double => timeSpan0.TotalSeconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan1 when format == SerializationFormat.Duration_Milliseconds => Convert.ToInt32(timeSpan1.TotalMilliseconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan2 when format == SerializationFormat.Duration_Milliseconds_Float || format == SerializationFormat.Duration_Milliseconds_Double => timeSpan2.TotalMilliseconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan3 when formatSpecifier != null => ToString(timeSpan3, formatSpecifier), + TimeSpan timeSpan4 => System.Xml.XmlConvert.ToString(timeSpan4), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/Utf8JsonRequestContent.cs index 5130928c6e0b..21ea0f6e6b98 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/Utf8JsonRequestContent.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -13,7 +13,7 @@ namespace Azure.Developer.LoadTesting { - internal class Utf8JsonRequestContent : RequestContent + internal partial class Utf8JsonRequestContent : RequestContent { private readonly MemoryStream _stream; private readonly RequestContent _content; @@ -25,20 +25,26 @@ public Utf8JsonRequestContent() JsonWriter = new Utf8JsonWriter(_stream); } + /// Gets the JsonWriter. public Utf8JsonWriter JsonWriter { get; } + /// The stream containing the data to be written. + /// The cancellation token to use. public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) { await JsonWriter.FlushAsync().ConfigureAwait(false); await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); } + /// The stream containing the data to be written. + /// The cancellation token to use. 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; diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTest.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTest.Serialization.cs index 606f479911b6..9621bd50d2bf 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTest.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTest.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; namespace Azure.Developer.LoadTesting { - public partial class LoadTest : IUtf8JsonSerializable, IJsonModel + /// Load test model. + public partial class LoadTest : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions /// 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; + string 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); @@ -67,6 +67,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit foreach (var item in EnvironmentVariables) { writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item.Value); } writer.WriteEndObject(); @@ -145,8 +150,13 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("engineBuiltInIdentityIds"u8); writer.WriteStartArray(); - foreach (var item in EngineBuiltInIdentityIds) + foreach (string item in EngineBuiltInIdentityIds) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); @@ -176,15 +186,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("lastModifiedBy"u8); writer.WriteStringValue(LastModifiedBy); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -193,22 +203,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - LoadTest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + LoadTest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual LoadTest JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static LoadTest DeserializeLoadTest(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -226,7 +241,7 @@ internal static LoadTest DeserializeLoadTest(JsonElement element, ModelReaderWri string displayName = default; string subnetId = default; LoadTestKind? kind = default; - bool? publicIPDisabled = default; + bool? publicIpDisabled = default; string keyvaultReferenceIdentityType = default; string keyvaultReferenceIdentityId = default; LoadTestingManagedIdentityType? metricsReferenceIdentityType = default; @@ -238,216 +253,228 @@ internal static LoadTest DeserializeLoadTest(JsonElement element, ModelReaderWri string createdBy = default; DateTimeOffset? lastModifiedDateTime = default; string lastModifiedBy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("passFailCriteria"u8)) + if (prop.NameEquals("passFailCriteria"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - passFailCriteria = PassFailCriteria.DeserializePassFailCriteria(property.Value, options); + passFailCriteria = PassFailCriteria.DeserializePassFailCriteria(prop.Value, options); continue; } - if (property.NameEquals("autoStopCriteria"u8)) + if (prop.NameEquals("autoStopCriteria"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - autoStopCriteria = AutoStopCriteria.DeserializeAutoStopCriteria(property.Value, options); + autoStopCriteria = AutoStopCriteria.DeserializeAutoStopCriteria(prop.Value, options); continue; } - if (property.NameEquals("secrets"u8)) + if (prop.NameEquals("secrets"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, TestSecret.DeserializeTestSecret(property0.Value, options)); + dictionary.Add(prop0.Name, TestSecret.DeserializeTestSecret(prop0.Value, options)); } secrets = dictionary; continue; } - if (property.NameEquals("certificate"u8)) + if (prop.NameEquals("certificate"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - certificate = TestCertificate.DeserializeTestCertificate(property.Value, options); + certificate = TestCertificate.DeserializeTestCertificate(prop.Value, options); continue; } - if (property.NameEquals("environmentVariables"u8)) + if (prop.NameEquals("environmentVariables"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, property0.Value.GetString()); + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } } environmentVariables = dictionary; continue; } - if (property.NameEquals("loadTestConfiguration"u8)) + if (prop.NameEquals("loadTestConfiguration"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - loadTestConfiguration = LoadTestConfiguration.DeserializeLoadTestConfiguration(property.Value, options); + loadTestConfiguration = LoadTestConfiguration.DeserializeLoadTestConfiguration(prop.Value, options); continue; } - if (property.NameEquals("baselineTestRunId"u8)) + if (prop.NameEquals("baselineTestRunId"u8)) { - baselineTestRunId = property.Value.GetString(); + baselineTestRunId = prop.Value.GetString(); continue; } - if (property.NameEquals("inputArtifacts"u8)) + if (prop.NameEquals("inputArtifacts"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - inputArtifacts = TestInputArtifacts.DeserializeTestInputArtifacts(property.Value, options); + inputArtifacts = TestInputArtifacts.DeserializeTestInputArtifacts(prop.Value, options); continue; } - if (property.NameEquals("testId"u8)) + if (prop.NameEquals("testId"u8)) { - testId = property.Value.GetString(); + testId = prop.Value.GetString(); continue; } - if (property.NameEquals("description"u8)) + if (prop.NameEquals("description"u8)) { - description = property.Value.GetString(); + description = prop.Value.GetString(); continue; } - if (property.NameEquals("displayName"u8)) + if (prop.NameEquals("displayName"u8)) { - displayName = property.Value.GetString(); + displayName = prop.Value.GetString(); continue; } - if (property.NameEquals("subnetId"u8)) + if (prop.NameEquals("subnetId"u8)) { - subnetId = property.Value.GetString(); + subnetId = prop.Value.GetString(); continue; } - if (property.NameEquals("kind"u8)) + if (prop.NameEquals("kind"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - kind = new LoadTestKind(property.Value.GetString()); + kind = new LoadTestKind(prop.Value.GetString()); continue; } - if (property.NameEquals("publicIPDisabled"u8)) + if (prop.NameEquals("publicIPDisabled"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - publicIPDisabled = property.Value.GetBoolean(); + publicIpDisabled = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("keyvaultReferenceIdentityType"u8)) + if (prop.NameEquals("keyvaultReferenceIdentityType"u8)) { - keyvaultReferenceIdentityType = property.Value.GetString(); + keyvaultReferenceIdentityType = prop.Value.GetString(); continue; } - if (property.NameEquals("keyvaultReferenceIdentityId"u8)) + if (prop.NameEquals("keyvaultReferenceIdentityId"u8)) { - keyvaultReferenceIdentityId = property.Value.GetString(); + keyvaultReferenceIdentityId = prop.Value.GetString(); continue; } - if (property.NameEquals("metricsReferenceIdentityType"u8)) + if (prop.NameEquals("metricsReferenceIdentityType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - metricsReferenceIdentityType = new LoadTestingManagedIdentityType(property.Value.GetString()); + metricsReferenceIdentityType = new LoadTestingManagedIdentityType(prop.Value.GetString()); continue; } - if (property.NameEquals("metricsReferenceIdentityId"u8)) + if (prop.NameEquals("metricsReferenceIdentityId"u8)) { - metricsReferenceIdentityId = property.Value.GetString(); + metricsReferenceIdentityId = prop.Value.GetString(); continue; } - if (property.NameEquals("engineBuiltInIdentityType"u8)) + if (prop.NameEquals("engineBuiltInIdentityType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - engineBuiltInIdentityType = new LoadTestingManagedIdentityType(property.Value.GetString()); + engineBuiltInIdentityType = new LoadTestingManagedIdentityType(prop.Value.GetString()); continue; } - if (property.NameEquals("engineBuiltInIdentityIds"u8)) + if (prop.NameEquals("engineBuiltInIdentityIds"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { - array.Add(item.GetString()); + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } } engineBuiltInIdentityIds = array; continue; } - if (property.NameEquals("estimatedVirtualUserHours"u8)) + if (prop.NameEquals("estimatedVirtualUserHours"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - estimatedVirtualUserHours = property.Value.GetDouble(); + estimatedVirtualUserHours = prop.Value.GetDouble(); continue; } - if (property.NameEquals("createdDateTime"u8)) + if (prop.NameEquals("createdDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - createdDateTime = property.Value.GetDateTimeOffset("O"); + createdDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("createdBy"u8)) + if (prop.NameEquals("createdBy"u8)) { - createdBy = property.Value.GetString(); + createdBy = prop.Value.GetString(); continue; } - if (property.NameEquals("lastModifiedDateTime"u8)) + if (prop.NameEquals("lastModifiedDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + lastModifiedDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("lastModifiedBy"u8)) + if (prop.NameEquals("lastModifiedBy"u8)) { - lastModifiedBy = property.Value.GetString(); + lastModifiedBy = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new LoadTest( passFailCriteria, autoStopCriteria, @@ -462,7 +489,7 @@ internal static LoadTest DeserializeLoadTest(JsonElement element, ModelReaderWri displayName, subnetId, kind, - publicIPDisabled, + publicIpDisabled, keyvaultReferenceIdentityType, keyvaultReferenceIdentityId, metricsReferenceIdentityType, @@ -474,13 +501,16 @@ internal static LoadTest DeserializeLoadTest(JsonElement element, ModelReaderWri createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -490,15 +520,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) } } - LoadTest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + LoadTest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual LoadTest PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeLoadTest(document.RootElement, options); } default: @@ -506,22 +541,14 @@ LoadTest IPersistableModel.Create(BinaryData data, ModelReaderWriterOp } } + /// The client options for reading and writing models. 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() + /// The to deserialize the from. + public static explicit operator LoadTest(Response response) { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); - return content; + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeLoadTest(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTest.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTest.cs index 803819e8ebe1..120111ed0886 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTest.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTest.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public LoadTest() @@ -85,8 +56,8 @@ public LoadTest() /// 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, double? estimatedVirtualUserHours, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + /// 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, double? estimatedVirtualUserHours, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary additionalBinaryDataProperties) { PassFailCriteria = passFailCriteria; AutoStopCriteria = autoStopCriteria; @@ -113,13 +84,15 @@ internal LoadTest(PassFailCriteria passFailCriteria, AutoStopCriteria autoStopCr CreatedBy = createdBy; LastModifiedDateTime = lastModifiedDateTime; LastModifiedBy = lastModifiedBy; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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 @@ -128,48 +101,70 @@ internal LoadTest(PassFailCriteria passFailCriteria, AutoStopCriteria autoStopCr /// 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; } + /// Estimated virtual user hours for the test. public double? EstimatedVirtualUserHours { 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestAdministrationClient.RestClient.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestAdministrationClient.RestClient.cs new file mode 100644 index 000000000000..e9d36a44f654 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestAdministrationClient.RestClient.cs @@ -0,0 +1,587 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + /// + public partial class LoadTestAdministrationClient + { + private static ResponseClassifier _pipelineMessageClassifier200; + private static ResponseClassifier _pipelineMessageClassifier200201; + private static ResponseClassifier _pipelineMessageClassifier201; + private static ResponseClassifier _pipelineMessageClassifier202; + private static ResponseClassifier _pipelineMessageClassifier204; + + private static ResponseClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = new StatusCodeClassifier(stackalloc ushort[] { 200 }); + + private static ResponseClassifier PipelineMessageClassifier200201 => _pipelineMessageClassifier200201 = new StatusCodeClassifier(stackalloc ushort[] { 200, 201 }); + + private static ResponseClassifier PipelineMessageClassifier201 => _pipelineMessageClassifier201 = new StatusCodeClassifier(stackalloc ushort[] { 201 }); + + private static ResponseClassifier PipelineMessageClassifier202 => _pipelineMessageClassifier202 = new StatusCodeClassifier(stackalloc ushort[] { 202 }); + + private static ResponseClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 = new StatusCodeClassifier(stackalloc ushort[] { 204 }); + + internal HttpMessage CreateCreateOrUpdateTestRequest(string testId, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200201); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/merge-patch+json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateCreateOrUpdateAppComponentsRequest(string testId, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/app-components", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200201); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/merge-patch+json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateCreateOrUpdateServerMetricsConfigRequest(string testId, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/server-metrics-config", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200201); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/merge-patch+json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetAppComponentsRequest(string testId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/app-components", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetServerMetricsConfigRequest(string testId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/server-metrics-config", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestRequest(string testId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestFileRequest(string testId, string fileName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + 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); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestFilesRequest(string testId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/files", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetTestFilesRequest(Uri nextPage, string testId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestsRequest(string @orderby, string search, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + 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", TypeFormatters.ConvertToString(lastModifiedStartTime, SerializationFormat.DateTime_RFC3339), true); + } + if (lastModifiedEndTime != null) + { + uri.AppendQuery("lastModifiedEndTime", TypeFormatters.ConvertToString(lastModifiedEndTime, SerializationFormat.DateTime_RFC3339), true); + } + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", TypeFormatters.ConvertToString(maxpagesize), true); + } + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetTestsRequest(Uri nextPage, string @orderby, string search, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateUploadTestFileRequest(string testId, string fileName, RequestContent content, string fileType, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + 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); + } + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier201); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/octet-stream"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteTestFileRequest(string testId, string fileName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + 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); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier204); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + + internal HttpMessage CreateDeleteTestRequest(string testId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier204); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + + internal HttpMessage CreateCreateOrUpdateTestProfileRequest(string testProfileId, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-profiles/", false); + uri.AppendPath(testProfileId, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200201); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/merge-patch+json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteTestProfileRequest(string testProfileId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-profiles/", false); + uri.AppendPath(testProfileId, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier204); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + + internal HttpMessage CreateGetTestProfileRequest(string testProfileId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-profiles/", false); + uri.AppendPath(testProfileId, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestProfilesRequest(int? maxpagesize, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, IEnumerable testProfileIds, IEnumerable testIds, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-profiles", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", TypeFormatters.ConvertToString(maxpagesize), true); + } + if (lastModifiedStartTime != null) + { + uri.AppendQuery("lastModifiedStartTime", TypeFormatters.ConvertToString(lastModifiedStartTime, SerializationFormat.DateTime_RFC3339), true); + } + if (lastModifiedEndTime != null) + { + uri.AppendQuery("lastModifiedEndTime", TypeFormatters.ConvertToString(lastModifiedEndTime, SerializationFormat.DateTime_RFC3339), true); + } + if (testProfileIds != null && !(testProfileIds is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) + { + uri.AppendQueryDelimited("testProfileIds", testProfileIds, ",", escape: true); + } + if (testIds != null && !(testIds is ChangeTrackingList changeTrackingList0 && changeTrackingList0.IsUndefined)) + { + uri.AppendQueryDelimited("testIds", testIds, ",", escape: true); + } + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetTestProfilesRequest(Uri nextPage, int? maxpagesize, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, IEnumerable testProfileIds, IEnumerable testIds, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateTriggerRequest(string triggerId, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/triggers/", false); + uri.AppendPath(triggerId, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200201); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/merge-patch+json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteTriggerRequest(string triggerId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/triggers/", false); + uri.AppendPath(triggerId, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier204); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + + internal HttpMessage CreateGetTriggerRequest(string triggerId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/triggers/", false); + uri.AppendPath(triggerId, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTriggersRequest(string testIds, string states, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + 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", TypeFormatters.ConvertToString(lastModifiedStartTime, SerializationFormat.DateTime_RFC3339), true); + } + if (lastModifiedEndTime != null) + { + uri.AppendQuery("lastModifiedEndTime", TypeFormatters.ConvertToString(lastModifiedEndTime, SerializationFormat.DateTime_RFC3339), true); + } + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", TypeFormatters.ConvertToString(maxpagesize), true); + } + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetTriggersRequest(Uri nextPage, string testIds, string states, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateNotificationRuleRequest(string notificationRuleId, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/notification-rules/", false); + uri.AppendPath(notificationRuleId, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200201); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/merge-patch+json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteNotificationRuleRequest(string notificationRuleId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/notification-rules/", false); + uri.AppendPath(notificationRuleId, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier204); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + + internal HttpMessage CreateGetNotificationRuleRequest(string notificationRuleId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/notification-rules/", false); + uri.AppendPath(notificationRuleId, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetNotificationRulesRequest(string testIds, string scopes, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + 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", TypeFormatters.ConvertToString(lastModifiedStartTime, SerializationFormat.DateTime_RFC3339), true); + } + if (lastModifiedEndTime != null) + { + uri.AppendQuery("lastModifiedEndTime", TypeFormatters.ConvertToString(lastModifiedEndTime, SerializationFormat.DateTime_RFC3339), true); + } + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", TypeFormatters.ConvertToString(maxpagesize), true); + } + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetNotificationRulesRequest(Uri nextPage, string testIds, string scopes, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCloneTestRequest(string testId, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath(":clone", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier202); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetOperationStatusRequest(string operationId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/operations/", false); + uri.AppendPath(operationId, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestAdministrationClient.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestAdministrationClient.cs index a9c98c20ecea..24dd4e600ab7 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestAdministrationClient.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestAdministrationClient.cs @@ -9,87 +9,87 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; namespace Azure.Developer.LoadTesting { - // Data plane generated client. - /// The LoadTestAdministration service client. + /// The LoadTestAdministrationClient. 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; + /// A credential used to authenticate to the service. + private readonly TokenCredential _tokenCredential; + private static readonly string[] AuthorizationScopes = new string[] { "https://cnt-prod.loadtesting.azure.com/.default" }; 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. + /// + /// A credential used to authenticate to the service. /// or is null. - public LoadTestAdministrationClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new LoadTestingClientOptions()) + /// is an empty string, and was expected to be non-empty. + public LoadTestAdministrationClient(string endpoint, TokenCredential credential) : this(endpoint, credential, new LoadTestingClientOptions()) { } /// Initializes a new instance of LoadTestAdministrationClient. - /// The to use. - /// A credential used to authenticate to an Azure Service. + /// + /// A credential used to authenticate to the service. /// The options for configuring the client. /// or is null. - public LoadTestAdministrationClient(Uri endpoint, TokenCredential credential, LoadTestingClientOptions options) + /// is an empty string, and was expected to be non-empty. + public LoadTestAdministrationClient(string endpoint, TokenCredential credential, LoadTestingClientOptions options) { - Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNullOrEmpty(endpoint, nameof(endpoint)); Argument.AssertNotNull(credential, nameof(credential)); + options ??= new LoadTestingClientOptions(); - ClientDiagnostics = new ClientDiagnostics(options, true); + _endpoint = new Uri($"https://{endpoint}"); _tokenCredential = credential; - _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier()); - _endpoint = endpoint; + Pipeline = HttpPipelineBuilder.Build(options, new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }); _apiVersion = options.Version; + ClientDiagnostics = new ClientDiagnostics(options, true); } + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + /// /// [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. - /// + /// 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. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateTest"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + using HttpMessage message = CreateCreateOrUpdateTestRequest(testId, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -102,30 +102,28 @@ public virtual async Task CreateOrUpdateTestAsync(string testId, Reque /// [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. - /// + /// 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. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateTest"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + using HttpMessage message = CreateCreateOrUpdateTestRequest(testId, content, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -135,12 +133,10 @@ public virtual Response CreateOrUpdateTest(string testId, RequestContent content } /// - /// [Protocol Method] Add an app component to a test. + /// [Protocol Method] Add an app component to a test by providing the resource Id, name and type. /// /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -149,22 +145,22 @@ public virtual Response CreateOrUpdateTest(string testId, RequestContent content /// 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. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateAppComponents"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + using HttpMessage message = CreateCreateOrUpdateAppComponentsRequest(testId, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -174,12 +170,10 @@ public virtual async Task CreateOrUpdateAppComponentsAsync(string test } /// - /// [Protocol Method] Add an app component to a test. + /// [Protocol Method] Add an app component to a test by providing the resource Id, name and type. /// /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -188,22 +182,22 @@ public virtual async Task CreateOrUpdateAppComponentsAsync(string test /// 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. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateAppComponents"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + using HttpMessage message = CreateCreateOrUpdateAppComponentsRequest(testId, content, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -216,9 +210,7 @@ public virtual Response CreateOrUpdateAppComponents(string testId, RequestConten /// [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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -227,22 +219,22 @@ public virtual Response CreateOrUpdateAppComponents(string testId, RequestConten /// 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. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateServerMetricsConfig"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + using HttpMessage message = CreateCreateOrUpdateServerMetricsConfigRequest(testId, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -255,9 +247,7 @@ public virtual async Task CreateOrUpdateServerMetricsConfigAsync(strin /// [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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -266,22 +256,22 @@ public virtual async Task CreateOrUpdateServerMetricsConfigAsync(strin /// 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. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateServerMetricsConfig"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + using HttpMessage message = CreateCreateOrUpdateServerMetricsConfigRequest(testId, content, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -290,52 +280,11 @@ public virtual Response CreateOrUpdateServerMetricsConfig(string testId, Request } } - /// 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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -343,21 +292,21 @@ public virtual Response GetAppComponents(string testId, Cance /// 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. + /// The request options, 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) + public virtual Response GetAppComponents(string testId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testId, nameof(testId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetAppComponents"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetAppComponents"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + using HttpMessage message = CreateGetAppComponentsRequest(testId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -370,14 +319,7 @@ public virtual async Task GetAppComponentsAsync(string testId, Request /// [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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -385,21 +327,21 @@ public virtual async Task GetAppComponentsAsync(string testId, Request /// 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. + /// The request options, 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) + public virtual async Task GetAppComponentsAsync(string testId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testId, nameof(testId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetAppComponents"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetAppComponents"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + using HttpMessage message = CreateGetAppComponentsRequest(testId, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -408,52 +350,45 @@ public virtual Response GetAppComponents(string testId, RequestContext context) } } - /// List server metrics configuration for the given test. + /// 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. + /// The cancellation token that can be used to cancel the operation. /// is null. /// is an empty string, and was expected to be non-empty. - public virtual async Task> GetServerMetricsConfigAsync(string testId, CancellationToken cancellationToken = default) + /// Service returned a non-success status code. + public virtual Response GetAppComponents(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); + Response result = GetAppComponents(testId, cancellationToken.ToRequestContext()); + return Response.FromValue((TestAppComponents)result, result); } - /// List server metrics configuration for the given test. + /// 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. + /// The cancellation token that can be used to cancel the operation. /// is null. /// is an empty string, and was expected to be non-empty. - public virtual Response GetServerMetricsConfig(string testId, CancellationToken cancellationToken = default) + /// Service returned a non-success status code. + public virtual async Task> GetAppComponentsAsync(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); + Response result = await GetAppComponentsAsync(testId, cancellationToken.ToRequestContext()).ConfigureAwait(false); + return Response.FromValue((TestAppComponents)result, result); } /// /// [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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -461,21 +396,21 @@ public virtual Response GetServerMetricsConfig(s /// 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. + /// The request options, 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) + public virtual Response GetServerMetricsConfig(string testId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testId, nameof(testId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetServerMetricsConfig"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetServerMetricsConfig"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + using HttpMessage message = CreateGetServerMetricsConfigRequest(testId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -488,14 +423,7 @@ public virtual async Task GetServerMetricsConfigAsync(string testId, R /// [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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -503,21 +431,21 @@ public virtual async Task GetServerMetricsConfigAsync(string testId, R /// 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. + /// The request options, 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) + public virtual async Task GetServerMetricsConfigAsync(string testId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testId, nameof(testId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetServerMetricsConfig"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetServerMetricsConfig"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + using HttpMessage message = CreateGetServerMetricsConfigRequest(testId, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -526,65 +454,64 @@ public virtual Response GetServerMetricsConfig(string testId, RequestContext con } } - /// 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. + /// 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 that can be used to cancel the operation. /// is null. /// is an empty string, and was expected to be non-empty. - public virtual async Task> GetTestAsync(string testId, CancellationToken cancellationToken = default) + /// Service returned a non-success status code. + public virtual Response GetServerMetricsConfig(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); + Response result = GetServerMetricsConfig(testId, cancellationToken.ToRequestContext()); + return Response.FromValue((TestServerMetricsConfiguration)result, result); } - /// 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. + /// 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 that can be used to cancel the operation. /// is null. /// is an empty string, and was expected to be non-empty. - public virtual Response GetTest(string testId, CancellationToken cancellationToken = default) + /// Service returned a non-success status code. + public virtual async Task> GetServerMetricsConfigAsync(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); + Response result = await GetServerMetricsConfigAsync(testId, cancellationToken.ToRequestContext()).ConfigureAwait(false); + return Response.FromValue((TestServerMetricsConfiguration)result, result); } /// /// [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. - /// + /// 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. + /// The request options, 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) + public virtual Response GetTest(string testId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testId, nameof(testId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTest"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTest"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + using HttpMessage message = CreateGetTestRequest(testId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -597,33 +524,26 @@ public virtual async Task GetTestAsync(string testId, RequestContext c /// [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. - /// + /// 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. + /// The request options, 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) + public virtual async Task GetTestAsync(string testId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testId, nameof(testId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTest"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTest"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + using HttpMessage message = CreateGetTestRequest(testId, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -632,71 +552,60 @@ public virtual Response GetTest(string testId, RequestContext context) } } - /// Get all the files that are associated with a test. + /// 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. - /// 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) + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual Response GetTest(string testId, 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); + Response result = GetTest(testId, cancellationToken.ToRequestContext()); + return Response.FromValue((LoadTest)result, result); } - /// Get all the files that are associated with a test. + /// 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. - /// 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) + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetTestAsync(string testId, 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); + Response result = await GetTestAsync(testId, cancellationToken.ToRequestContext()).ConfigureAwait(false); + return Response.FromValue((LoadTest)result, result); } /// /// [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. - /// + /// 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. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestFile"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + using HttpMessage message = CreateGetTestFileRequest(testId, fileName, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -709,35 +618,28 @@ public virtual async Task GetTestFileAsync(string testId, string fileN /// [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. - /// + /// 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. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestFile"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + using HttpMessage message = CreateGetTestFileRequest(testId, fileName, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -746,101 +648,61 @@ public virtual Response GetTestFile(string testId, string fileName, RequestConte } } - /// - /// 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. + /// 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 that can be used to cancel the operation. + /// 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) + /// Service returned a non-success status code. + public virtual Response GetTestFile(string testId, string fileName, 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); + Response result = GetTestFile(testId, fileName, cancellationToken.ToRequestContext()); + return Response.FromValue((TestFileInfo)result, result); } - /// - /// 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. + /// 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 that can be used to cancel the operation. + /// 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) + /// Service returned a non-success status code. + public virtual async Task> GetTestFileAsync(string testId, string fileName, 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); + Response result = await GetTestFileAsync(testId, fileName, cancellationToken.ToRequestContext()).ConfigureAwait(false); + return Response.FromValue((TestFileInfo)result, result); } /// - /// [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. + /// [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. - /// + /// 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. - /// - /// 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. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request options, 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. - internal virtual async Task UploadTestFileAsync(string testId, string fileName, RequestContent content, string fileType = null, RequestContext context = null) + public virtual Pageable GetTestFiles(string testId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testId, nameof(testId)); - Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.UploadTestFile"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestFiles"); scope.Start(); try { - using HttpMessage message = CreateUploadTestFileRequest(testId, fileName, content, fileType, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + return new LoadTestAdministrationClientGetTestFilesCollectionResult(this, testId, context); } catch (Exception e) { @@ -850,46 +712,278 @@ internal virtual async Task UploadTestFileAsync(string testId, string } /// - /// [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. + /// [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. - /// + /// 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. - /// - /// 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) + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request options, 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 AsyncPageable GetTestFilesAsync(string testId, RequestContext context) + { + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestFiles"); + scope.Start(); + try + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + return new LoadTestAdministrationClientGetTestFilesAsyncCollectionResult(this, testId, 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 that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual Pageable GetTestFiles(string testId, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(testId, nameof(testId)); - Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); - Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.UploadTestFile"); + return new LoadTestAdministrationClientGetTestFilesCollectionResultOfT(this, testId, cancellationToken.ToRequestContext()); + } + + /// 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 that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual AsyncPageable GetTestFilesAsync(string testId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + return new LoadTestAdministrationClientGetTestFilesAsyncCollectionResultOfT(this, testId, cancellationToken.ToRequestContext()); + } + + /// + /// [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. + /// + /// + /// + /// + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual Pageable GetTests(string @orderby, string search, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTests"); + scope.Start(); + try + { + return new LoadTestAdministrationClientGetTestsCollectionResult( + this, + @orderby, + search, + lastModifiedStartTime, + lastModifiedEndTime, + maxpagesize, + context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [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. + /// + /// + /// + /// + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual AsyncPageable GetTestsAsync(string @orderby, string search, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTests"); + scope.Start(); + try + { + return new LoadTestAdministrationClientGetTestsAsyncCollectionResult( + this, + @orderby, + search, + lastModifiedStartTime, + lastModifiedEndTime, + maxpagesize, + context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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 that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual Pageable GetTests(string @orderby = default, string search = default, DateTimeOffset? lastModifiedStartTime = default, DateTimeOffset? lastModifiedEndTime = default, int? maxpagesize = default, CancellationToken cancellationToken = default) + { + return new LoadTestAdministrationClientGetTestsCollectionResultOfT( + this, + @orderby, + search, + lastModifiedStartTime, + lastModifiedEndTime, + maxpagesize, + cancellationToken.ToRequestContext()); + } + + /// + /// 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 that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual AsyncPageable GetTestsAsync(string @orderby = default, string search = default, DateTimeOffset? lastModifiedStartTime = default, DateTimeOffset? lastModifiedEndTime = default, int? maxpagesize = default, CancellationToken cancellationToken = default) + { + return new LoadTestAdministrationClientGetTestsAsyncCollectionResultOfT( + this, + @orderby, + search, + lastModifiedStartTime, + lastModifiedEndTime, + maxpagesize, + cancellationToken.ToRequestContext()); + } + + /// + /// [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. + /// + /// + /// + /// + /// 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. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual Response UploadTestFile(string testId, string fileName, RequestContent content, string fileType = default, RequestContext context = null) + { + using DiagnosticScope 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; + } + } + + /// + /// [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. + /// + /// + /// + /// + /// 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. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual async Task UploadTestFileAsync(string testId, string fileName, RequestContent content, string fileType = default, RequestContext context = null) + { + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.UploadTestFile"); scope.Start(); try { using HttpMessage message = CreateUploadTestFileRequest(testId, fileName, content, fileType, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -898,35 +992,72 @@ internal virtual Response UploadTestFile(string testId, string fileName, Request } } - // The convenience method is omitted here because it has exactly the same parameter list as the corresponding 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. + /// + /// + /// 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 that can be used to cancel the operation. + /// Service returned a non-success status code. + internal virtual Response UploadTestFile(string testId, string fileName, BinaryData body, LoadTestingFileType? fileType = default, CancellationToken cancellationToken = default) + { + Response result = UploadTestFile(testId, fileName, RequestContent.Create(body), fileType?.ToString(), cancellationToken.ToRequestContext()); + return Response.FromValue((TestFileInfo)result, result); + } + + /// + /// 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 that can be used to cancel the operation. + /// Service returned a non-success status code. + internal virtual async Task> UploadTestFileAsync(string testId, string fileName, BinaryData body, LoadTestingFileType? fileType = default, CancellationToken cancellationToken = default) + { + Response result = await UploadTestFileAsync(testId, fileName, RequestContent.Create(body), fileType?.ToString(), cancellationToken.ToRequestContext()).ConfigureAwait(false); + return Response.FromValue((TestFileInfo)result, result); + } + /// /// [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. - /// + /// 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. + /// The request options, 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) + public virtual Response DeleteTestFile(string testId, string fileName, RequestContext context) { - Argument.AssertNotNullOrEmpty(testId, nameof(testId)); - Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTestFile"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTestFile"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + using HttpMessage message = CreateDeleteTestFileRequest(testId, fileName, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -935,35 +1066,32 @@ public virtual async Task DeleteTestFileAsync(string testId, string fi } } - // 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. - /// + /// 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. + /// The request options, 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) + public virtual async Task DeleteTestFileAsync(string testId, string fileName, RequestContext context) { - Argument.AssertNotNullOrEmpty(testId, nameof(testId)); - Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTestFile"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTestFile"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + using HttpMessage message = CreateDeleteTestFileRequest(testId, fileName, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -972,33 +1100,60 @@ public virtual Response DeleteTestFile(string testId, string fileName, RequestCo } } - // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// Delete file by the file name for 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 that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual Response DeleteTestFile(string testId, string fileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + return DeleteTestFile(testId, fileName, cancellationToken.ToRequestContext()); + } + + /// Delete file by the file name for 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 that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task DeleteTestFileAsync(string testId, string fileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + return await DeleteTestFileAsync(testId, fileName, cancellationToken.ToRequestContext()).ConfigureAwait(false); + } + /// /// [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. - /// + /// 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. + /// The request options, 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) + public virtual Response DeleteTest(string testId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testId, nameof(testId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTest"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTest"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + using HttpMessage message = CreateDeleteTestRequest(testId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -1007,33 +1162,30 @@ public virtual async Task DeleteTestAsync(string testId, RequestContex } } - // 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. - /// + /// 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. + /// The request options, 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) + public virtual async Task DeleteTestAsync(string testId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testId, nameof(testId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTest"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTest"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + using HttpMessage message = CreateDeleteTestRequest(testId, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -1042,34 +1194,58 @@ public virtual Response DeleteTest(string testId, RequestContext context = null) } } + /// Delete a test by its test Id. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual Response DeleteTest(string testId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + return DeleteTest(testId, cancellationToken.ToRequestContext()); + } + + /// Delete a test by its test Id. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task DeleteTestAsync(string testId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + return await DeleteTestAsync(testId, cancellationToken.ToRequestContext()).ConfigureAwait(false); + } + /// - /// [Protocol Method] Create a new test profile or update an existing test profile. + /// [Protocol Method] Create a new test profile or update an existing test profile by providing the test profile Id. /// /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// + /// 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. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateTestProfile"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + Argument.AssertNotNull(content, nameof(content)); + using HttpMessage message = CreateCreateOrUpdateTestProfileRequest(testProfileId, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -1079,33 +1255,31 @@ public virtual async Task CreateOrUpdateTestProfileAsync(string testPr } /// - /// [Protocol Method] Create a new test profile or update an existing test profile. + /// [Protocol Method] Create a new test profile or update an existing test profile by providing the test profile Id. /// /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// + /// 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. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateTestProfile"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + Argument.AssertNotNull(content, nameof(content)); + using HttpMessage message = CreateCreateOrUpdateTestProfileRequest(testProfileId, content, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -1114,33 +1288,30 @@ public virtual Response CreateOrUpdateTestProfile(string testProfileId, RequestC } } - // 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. + /// [Protocol Method] Delete a test profile by its test profile Id. /// /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// + /// 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. + /// The request options, 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) + public virtual Response DeleteTestProfile(string testProfileId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTestProfile"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTestProfile"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + using HttpMessage message = CreateDeleteTestProfileRequest(testProfileId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -1149,33 +1320,30 @@ public virtual async Task DeleteTestProfileAsync(string testProfileId, } } - // 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. + /// [Protocol Method] Delete a test profile by its test profile Id. /// /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// + /// 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. + /// The request options, 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) + public virtual async Task DeleteTestProfileAsync(string testProfileId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTestProfile"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTestProfile"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + using HttpMessage message = CreateDeleteTestProfileRequest(testProfileId, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -1184,67 +1352,56 @@ public virtual Response DeleteTestProfile(string testProfileId, RequestContext c } } - /// Get load test profile details. + /// Delete a test profile by its test profile Id. /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. - /// The cancellation token to use. + /// The cancellation token that can be used to cancel the operation. /// 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) + /// Service returned a non-success status code. + public virtual Response DeleteTestProfile(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); + return DeleteTestProfile(testProfileId, cancellationToken.ToRequestContext()); } - /// Get load test profile details. + /// Delete a test profile by its test profile Id. /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. - /// The cancellation token to use. + /// The cancellation token that can be used to cancel the operation. /// 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) + /// Service returned a non-success status code. + public virtual async Task DeleteTestProfileAsync(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); + return await DeleteTestProfileAsync(testProfileId, cancellationToken.ToRequestContext()).ConfigureAwait(false); } /// - /// [Protocol Method] Get load test profile details. + /// [Protocol Method] Get load test profile details by test profile 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. - /// + /// 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. + /// The request options, 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) + public virtual Response GetTestProfile(string testProfileId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestProfile"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestProfile"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + using HttpMessage message = CreateGetTestProfileRequest(testProfileId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -1254,36 +1411,133 @@ public virtual async Task GetTestProfileAsync(string testProfileId, Re } /// - /// [Protocol Method] Get load test profile details. + /// [Protocol Method] Get load test profile details by test profile 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. - /// + /// 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. + /// The request options, 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) + public virtual async Task GetTestProfileAsync(string testProfileId, RequestContext context) + { + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestProfile"); + scope.Start(); + try + { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + + using HttpMessage message = CreateGetTestProfileRequest(testProfileId, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get load test profile details by test profile Id. + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual Response GetTestProfile(string testProfileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + + Response result = GetTestProfile(testProfileId, cancellationToken.ToRequestContext()); + return Response.FromValue((TestProfile)result, result); + } + + /// Get load test profile details by test profile Id. + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetTestProfileAsync(string testProfileId, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestProfile"); + Response result = await GetTestProfileAsync(testProfileId, cancellationToken.ToRequestContext()).ConfigureAwait(false); + return Response.FromValue((TestProfile)result, result); + } + + /// + /// [Protocol Method] Get all test profiles for the given filters. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual Pageable GetTestProfiles(int? maxpagesize, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, IEnumerable testProfileIds, IEnumerable testIds, RequestContext context) + { + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestProfiles"); scope.Start(); try { - using HttpMessage message = CreateGetTestProfileRequest(testProfileId, context); - return _pipeline.ProcessMessage(message, context); + return new LoadTestAdministrationClientGetTestProfilesCollectionResult( + this, + maxpagesize, + lastModifiedStartTime, + lastModifiedEndTime, + testProfileIds, + testIds, + context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get all test profiles for the given filters. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual AsyncPageable GetTestProfilesAsync(int? maxpagesize, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, IEnumerable testProfileIds, IEnumerable testIds, RequestContext context) + { + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestProfiles"); + scope.Start(); + try + { + return new LoadTestAdministrationClientGetTestProfilesAsyncCollectionResult( + this, + maxpagesize, + lastModifiedStartTime, + lastModifiedEndTime, + testProfileIds, + testIds, + context); } catch (Exception e) { @@ -1292,34 +1546,72 @@ public virtual Response GetTestProfile(string testProfileId, RequestContext cont } } + /// Get all test profiles for the given filters. + /// 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 that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual Pageable GetTestProfiles(int? maxpagesize = default, DateTimeOffset? lastModifiedStartTime = default, DateTimeOffset? lastModifiedEndTime = default, IEnumerable testProfileIds = default, IEnumerable testIds = default, CancellationToken cancellationToken = default) + { + return new LoadTestAdministrationClientGetTestProfilesCollectionResultOfT( + this, + maxpagesize, + lastModifiedStartTime, + lastModifiedEndTime, + testProfileIds, + testIds, + cancellationToken.ToRequestContext()); + } + + /// Get all test profiles for the given filters. + /// 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 that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual AsyncPageable GetTestProfilesAsync(int? maxpagesize = default, DateTimeOffset? lastModifiedStartTime = default, DateTimeOffset? lastModifiedEndTime = default, IEnumerable testProfileIds = default, IEnumerable testIds = default, CancellationToken cancellationToken = default) + { + return new LoadTestAdministrationClientGetTestProfilesAsyncCollectionResultOfT( + this, + maxpagesize, + lastModifiedStartTime, + lastModifiedEndTime, + testProfileIds, + testIds, + cancellationToken.ToRequestContext()); + } + /// /// [Protocol Method] Create or update operation template. /// /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// + /// 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. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateTrigger"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); + Argument.AssertNotNull(content, nameof(content)); + using HttpMessage message = CreateCreateOrUpdateTriggerRequest(triggerId, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -1332,30 +1624,28 @@ public virtual async Task CreateOrUpdateTriggerAsync(string triggerId, /// [Protocol Method] Create or update operation template. /// /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// + /// 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. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateTrigger"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); + Argument.AssertNotNull(content, nameof(content)); + using HttpMessage message = CreateCreateOrUpdateTriggerRequest(triggerId, content, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -1364,33 +1654,30 @@ public virtual Response CreateOrUpdateTrigger(string triggerId, RequestContent c } } - // 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. - /// + /// 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. + /// The request options, 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) + public virtual Response DeleteTrigger(string triggerId, RequestContext context) { - Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTrigger"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTrigger"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); + using HttpMessage message = CreateDeleteTriggerRequest(triggerId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -1399,33 +1686,30 @@ public virtual async Task DeleteTriggerAsync(string triggerId, Request } } - // 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. - /// + /// 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. + /// The request options, 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) + public virtual async Task DeleteTriggerAsync(string triggerId, RequestContext context) { - Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTrigger"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTrigger"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); + using HttpMessage message = CreateDeleteTriggerRequest(triggerId, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -1434,65 +1718,56 @@ public virtual Response DeleteTrigger(string triggerId, RequestContext context = } } - /// Resource read operation template. + /// Resource delete operation template. /// The unique identifier of the trigger. - /// The cancellation token to use. + /// The cancellation token that can be used to cancel the operation. /// is null. /// is an empty string, and was expected to be non-empty. - public virtual async Task> GetTriggerAsync(string triggerId, CancellationToken cancellationToken = default) + /// Service returned a non-success status code. + public virtual Response DeleteTrigger(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(LoadTestingTrigger.FromResponse(response), response); + return DeleteTrigger(triggerId, cancellationToken.ToRequestContext()); } - /// Resource read operation template. + /// Resource delete operation template. /// The unique identifier of the trigger. - /// The cancellation token to use. + /// The cancellation token that can be used to cancel the operation. /// is null. /// is an empty string, and was expected to be non-empty. - public virtual Response GetTrigger(string triggerId, CancellationToken cancellationToken = default) + /// Service returned a non-success status code. + public virtual async Task DeleteTriggerAsync(string triggerId, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetTrigger(triggerId, context); - return Response.FromValue(LoadTestingTrigger.FromResponse(response), response); + return await DeleteTriggerAsync(triggerId, cancellationToken.ToRequestContext()).ConfigureAwait(false); } /// /// [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. - /// + /// 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. + /// The request options, 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) + public virtual Response GetTrigger(string triggerId, RequestContext context) { - Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTrigger"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTrigger"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); + using HttpMessage message = CreateGetTriggerRequest(triggerId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -1505,33 +1780,130 @@ public virtual async Task GetTriggerAsync(string triggerId, RequestCon /// [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. - /// + /// 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. + /// The request options, 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) + public virtual async Task GetTriggerAsync(string triggerId, RequestContext context) + { + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTrigger"); + scope.Start(); + try + { + Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); + + using HttpMessage message = CreateGetTriggerRequest(triggerId, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Resource read operation template. + /// The unique identifier of the trigger. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual Response GetTrigger(string triggerId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); + + Response result = GetTrigger(triggerId, cancellationToken.ToRequestContext()); + return Response.FromValue((LoadTestingTrigger)result, result); + } + + /// Resource read operation template. + /// The unique identifier of the trigger. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetTriggerAsync(string triggerId, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(triggerId, nameof(triggerId)); - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTrigger"); + Response result = await GetTriggerAsync(triggerId, cancellationToken.ToRequestContext()).ConfigureAwait(false); + return Response.FromValue((LoadTestingTrigger)result, result); + } + + /// + /// [Protocol Method] Resource list operation template. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// 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 request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual Pageable GetTriggers(string testIds, string states, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTriggers"); scope.Start(); try { - using HttpMessage message = CreateGetTriggerRequest(triggerId, context); - return _pipeline.ProcessMessage(message, context); + return new LoadTestAdministrationClientGetTriggersCollectionResult( + this, + testIds, + states, + lastModifiedStartTime, + lastModifiedEndTime, + maxpagesize, + context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Resource list operation template. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// 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 request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual AsyncPageable GetTriggersAsync(string testIds, string states, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTriggers"); + scope.Start(); + try + { + return new LoadTestAdministrationClientGetTriggersAsyncCollectionResult( + this, + testIds, + states, + lastModifiedStartTime, + lastModifiedEndTime, + maxpagesize, + context); } catch (Exception e) { @@ -1540,34 +1912,72 @@ public virtual Response GetTrigger(string triggerId, RequestContext 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 that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual Pageable GetTriggers(string testIds = default, TriggerState? states = default, DateTimeOffset? lastModifiedStartTime = default, DateTimeOffset? lastModifiedEndTime = default, int? maxpagesize = default, CancellationToken cancellationToken = default) + { + return new LoadTestAdministrationClientGetTriggersCollectionResultOfT( + this, + testIds, + states?.ToString(), + lastModifiedStartTime, + lastModifiedEndTime, + maxpagesize, + cancellationToken.ToRequestContext()); + } + + /// 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 that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual AsyncPageable GetTriggersAsync(string testIds = default, TriggerState? states = default, DateTimeOffset? lastModifiedStartTime = default, DateTimeOffset? lastModifiedEndTime = default, int? maxpagesize = default, CancellationToken cancellationToken = default) + { + return new LoadTestAdministrationClientGetTriggersAsyncCollectionResultOfT( + this, + testIds, + states?.ToString(), + lastModifiedStartTime, + lastModifiedEndTime, + maxpagesize, + cancellationToken.ToRequestContext()); + } + /// /// [Protocol Method] Create or update operation template. /// /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// + /// 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. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateNotificationRule"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); + Argument.AssertNotNull(content, nameof(content)); + using HttpMessage message = CreateCreateOrUpdateNotificationRuleRequest(notificationRuleId, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -1580,30 +1990,28 @@ public virtual async Task CreateOrUpdateNotificationRuleAsync(string n /// [Protocol Method] Create or update operation template. /// /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// + /// 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. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateNotificationRule"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); + Argument.AssertNotNull(content, nameof(content)); + using HttpMessage message = CreateCreateOrUpdateNotificationRuleRequest(notificationRuleId, content, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -1612,33 +2020,30 @@ public virtual Response CreateOrUpdateNotificationRule(string notificationRuleId } } - // 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. - /// + /// 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. + /// The request options, 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) + public virtual Response DeleteNotificationRule(string notificationRuleId, RequestContext context) { - Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteNotificationRule"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteNotificationRule"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); + using HttpMessage message = CreateDeleteNotificationRuleRequest(notificationRuleId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -1647,33 +2052,30 @@ public virtual async Task DeleteNotificationRuleAsync(string notificat } } - // 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. - /// + /// 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. + /// The request options, 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) + public virtual async Task DeleteNotificationRuleAsync(string notificationRuleId, RequestContext context) { - Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteNotificationRule"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteNotificationRule"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); + using HttpMessage message = CreateDeleteNotificationRuleRequest(notificationRuleId, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -1682,65 +2084,56 @@ public virtual Response DeleteNotificationRule(string notificationRuleId, Reques } } - /// Resource read operation template. + /// Resource delete operation template. /// The unique identifier of the notification rule. - /// The cancellation token to use. + /// The cancellation token that can be used to cancel the operation. /// is null. /// is an empty string, and was expected to be non-empty. - public virtual async Task> GetNotificationRuleAsync(string notificationRuleId, CancellationToken cancellationToken = default) + /// Service returned a non-success status code. + public virtual Response DeleteNotificationRule(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); + return DeleteNotificationRule(notificationRuleId, cancellationToken.ToRequestContext()); } - /// Resource read operation template. + /// Resource delete operation template. /// The unique identifier of the notification rule. - /// The cancellation token to use. + /// The cancellation token that can be used to cancel the operation. /// is null. /// is an empty string, and was expected to be non-empty. - public virtual Response GetNotificationRule(string notificationRuleId, CancellationToken cancellationToken = default) + /// Service returned a non-success status code. + public virtual async Task DeleteNotificationRuleAsync(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); + return await DeleteNotificationRuleAsync(notificationRuleId, cancellationToken.ToRequestContext()).ConfigureAwait(false); } /// /// [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. - /// + /// 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. + /// The request options, 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) + public virtual Response GetNotificationRule(string notificationRuleId, RequestContext context) { - Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetNotificationRule"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetNotificationRule"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); + using HttpMessage message = CreateGetNotificationRuleRequest(notificationRuleId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -1753,33 +2146,26 @@ public virtual async Task GetNotificationRuleAsync(string notification /// [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. - /// + /// 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. + /// The request options, 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) + public virtual async Task GetNotificationRuleAsync(string notificationRuleId, RequestContext context) { - Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetNotificationRule"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetNotificationRule"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); + using HttpMessage message = CreateGetNotificationRuleRequest(notificationRuleId, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -1788,65 +2174,64 @@ public virtual Response GetNotificationRule(string notificationRuleId, RequestCo } } - /// 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) + /// Resource read operation template. + /// The unique identifier of the notification rule. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual Response GetNotificationRule(string notificationRuleId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); + Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetOperationStatusAsync(operationId, context).ConfigureAwait(false); - return Response.FromValue(OperationStatus.FromResponse(response), response); + Response result = GetNotificationRule(notificationRuleId, cancellationToken.ToRequestContext()); + return Response.FromValue((NotificationRule)result, result); } - /// 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) + /// Resource read operation template. + /// The unique identifier of the notification rule. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetNotificationRuleAsync(string notificationRuleId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); + Argument.AssertNotNullOrEmpty(notificationRuleId, nameof(notificationRuleId)); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetOperationStatus(operationId, context); - return Response.FromValue(OperationStatus.FromResponse(response), response); + Response result = await GetNotificationRuleAsync(notificationRuleId, cancellationToken.ToRequestContext()).ConfigureAwait(false); + return Response.FromValue((NotificationRule)result, result); } /// - /// [Protocol Method] Get the status of a long running operation. + /// [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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// - /// 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. + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. /// Service returned a non-success status code. /// The response returned from the service. - public virtual async Task GetOperationStatusAsync(string operationId, RequestContext context) + public virtual Pageable GetNotificationRules(string testIds, string scopes, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) { - Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetOperationStatus"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetNotificationRules"); scope.Start(); try { - using HttpMessage message = CreateGetOperationStatusRequest(operationId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return new LoadTestAdministrationClientGetNotificationRulesCollectionResult( + this, + testIds, + scopes, + lastModifiedStartTime, + lastModifiedEndTime, + maxpagesize, + context); } catch (Exception e) { @@ -1856,36 +2241,35 @@ public virtual async Task GetOperationStatusAsync(string operationId, } /// - /// [Protocol Method] Get the status of a long running operation. + /// [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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// - /// 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. + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. /// Service returned a non-success status code. /// The response returned from the service. - public virtual Response GetOperationStatus(string operationId, RequestContext context) + public virtual AsyncPageable GetNotificationRulesAsync(string testIds, string scopes, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) { - Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetOperationStatus"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetNotificationRules"); scope.Start(); try { - using HttpMessage message = CreateGetOperationStatusRequest(operationId, context); - return _pipeline.ProcessMessage(message, context); + return new LoadTestAdministrationClientGetNotificationRulesAsyncCollectionResult( + this, + testIds, + scopes, + lastModifiedStartTime, + lastModifiedEndTime, + maxpagesize, + context); } catch (Exception e) { @@ -1894,199 +2278,24 @@ public virtual Response GetOperationStatus(string operationId, RequestContext co } } - /// 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); - } - - /// 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 => LoadTestingTrigger.DeserializeLoadTestingTrigger(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 => LoadTestingTrigger.DeserializeLoadTestingTrigger(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) + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual Pageable GetNotificationRules(string testIds = default, string scopes = default, DateTimeOffset? lastModifiedStartTime = default, DateTimeOffset? lastModifiedEndTime = default, int? maxpagesize = default, 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); + return new LoadTestAdministrationClientGetNotificationRulesCollectionResultOfT( + this, + testIds, + scopes, + lastModifiedStartTime, + lastModifiedEndTime, + maxpagesize, + cancellationToken.ToRequestContext()); } /// Resource list operation template. @@ -2095,151 +2304,136 @@ public virtual AsyncPageable GetNotificationRulesAsync(string /// 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) + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual AsyncPageable GetNotificationRulesAsync(string testIds = default, string scopes = default, DateTimeOffset? lastModifiedStartTime = default, DateTimeOffset? lastModifiedEndTime = default, int? maxpagesize = default, 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); + return new LoadTestAdministrationClientGetNotificationRulesAsyncCollectionResultOfT( + this, + testIds, + scopes, + lastModifiedStartTime, + lastModifiedEndTime, + maxpagesize, + cancellationToken.ToRequestContext()); } - /// - /// [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) + /// Clone the given test with optional overrides applied to the clone 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. + /// The content to send as the body of the request. + /// The request options, 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. + /// The response returned from the service. + public virtual Operation CloneTest(WaitUntil waitUntil, string testId, RequestContent content, RequestContext context = 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 => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetNotificationRules", "value", "nextLink", maxpagesize, context); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CloneTest"); + scope.Start(); + try + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + + 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; + } } - /// - /// [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) + /// Clone the given test with optional overrides applied to the clone 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. + /// The content to send as the body of the request. + /// The request options, 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. + /// The response returned from the service. + public virtual async Task> CloneTestAsync(WaitUntil waitUntil, string testId, RequestContent content, RequestContext context = 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 => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetNotificationRules", "value", "nextLink", maxpagesize, context); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CloneTest"); + scope.Start(); + try + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + + using HttpMessage message = CreateCloneTestRequest(testId, content, context); + return await ProtocolOperationHelpers.ProcessMessageAsync(Pipeline, message, ClientDiagnostics, "LoadTestAdministrationClient.CloneTestAsync", OperationFinalStateVia.OperationLocation, context, waitUntil).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } - /// Clone a load test. + /// Clone the given test with optional overrides applied to the clone 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. + /// The cancellation token that can be used to cancel the operation. /// 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) + /// or is an empty string, and was expected to be non-empty. + public virtual Operation CloneTest(WaitUntil waitUntil, string testId, string newTestId, string displayName = default, string description = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(testId, nameof(testId)); - Argument.AssertNotNull(newTestId, nameof(newTestId)); + Argument.AssertNotNullOrEmpty(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"); + CloneTestRequest1 spreadModel = new CloneTestRequest1(newTestId, displayName, description, default); + Operation result = CloneTest(waitUntil, testId, spreadModel, cancellationToken.ToRequestContext()); + return ProtocolOperationHelpers.Convert(result, response => (LoadTest)response, ClientDiagnostics, "LoadTestAdministrationClient.CloneTest"); } - /// Clone a load test. + /// Clone the given test with optional overrides applied to the clone 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. + /// The cancellation token that can be used to cancel the operation. /// 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) + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> CloneTestAsync(WaitUntil waitUntil, string testId, string newTestId, string displayName = default, string description = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(testId, nameof(testId)); - Argument.AssertNotNull(newTestId, nameof(newTestId)); + Argument.AssertNotNullOrEmpty(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"); + CloneTestRequest1 spreadModel = new CloneTestRequest1(newTestId, displayName, description, default); + Operation result = await CloneTestAsync(waitUntil, testId, spreadModel, cancellationToken.ToRequestContext()).ConfigureAwait(false); + return ProtocolOperationHelpers.Convert(result, response => (LoadTest)response, ClientDiagnostics, "LoadTestAdministrationClient.CloneTestAsync"); } /// - /// [Protocol Method] Clone a load test. + /// [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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// - /// 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. + /// The unique ID of the operation. + /// The request options, 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 representing an asynchronous operation on the service. - public virtual async Task> CloneTestAsync(WaitUntil waitUntil, string testId, RequestContent content, RequestContext context = null) + /// The response returned from the service. + public virtual Response GetOperationStatus(string operationId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testId, nameof(testId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CloneTest"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetOperationStatus"); 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); + Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); + + using HttpMessage message = CreateGetOperationStatusRequest(operationId, context); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -2249,39 +2443,29 @@ public virtual async Task> CloneTestAsync(WaitUntil waitUn } /// - /// [Protocol Method] Clone a load test. + /// [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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// - /// 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. + /// The unique ID of the operation. + /// The request options, 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 representing an asynchronous operation on the service. - public virtual Operation CloneTest(WaitUntil waitUntil, string testId, RequestContent content, RequestContext context = null) + /// The response returned from the service. + public virtual async Task GetOperationStatusAsync(string operationId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testId, nameof(testId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CloneTest"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetOperationStatus"); scope.Start(); try { - using HttpMessage message = CreateCloneTestRequest(testId, content, context); - return ProtocolOperationHelpers.ProcessMessage(_pipeline, message, ClientDiagnostics, "LoadTestAdministrationClient.CloneTest", OperationFinalStateVia.OperationLocation, context, waitUntil); + Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); + + using HttpMessage message = CreateGetOperationStatusRequest(operationId, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -2290,615 +2474,32 @@ public virtual Operation CloneTest(WaitUntil waitUntil, string testI } } - 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; - 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; - 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; - 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; - 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) + /// Get the status of a long running operation. + /// The unique ID of the operation. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual Response GetOperationStatus(string operationId, CancellationToken cancellationToken = default) { - 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; - return message; - } + Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); - 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; + Response result = GetOperationStatus(operationId, cancellationToken.ToRequestContext()); + return Response.FromValue((OperationStatus)result, result); } - internal HttpMessage CreateGetNotificationRulesRequest(string testIds, string scopes, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + /// Get the status of a long running operation. + /// The unique ID of the operation. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetOperationStatusAsync(string operationId, CancellationToken cancellationToken = default) { - 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; - } + Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); - 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; + Response result = await GetOperationStatusAsync(operationId, cancellationToken.ToRequestContext()).ConfigureAwait(false); + return Response.FromValue((OperationStatus)result, result); } - - 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestConfiguration.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestConfiguration.Serialization.cs index 98caec51a750..a6aedc333316 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestConfiguration.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestConfiguration.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Configurations for the load test. + public partial class LoadTestConfiguration : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW /// 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; + string 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); @@ -58,21 +57,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("regionalLoadTestConfig"u8); writer.WriteStartArray(); - foreach (var item in RegionalLoadTestConfiguration) + foreach (RegionalConfiguration item in RegionalLoadTestConfiguration) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -81,104 +80,110 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - LoadTestConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + LoadTestConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual LoadTestConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static LoadTestConfiguration DeserializeLoadTestConfiguration(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } int? engineInstances = default; - bool? splitAllCSVs = 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()) + OptionalLoadTestConfiguration optionalLoadTestConfiguration = default; + IList regionalLoadTestConfiguration = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("engineInstances"u8)) + if (prop.NameEquals("engineInstances"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - engineInstances = property.Value.GetInt32(); + engineInstances = prop.Value.GetInt32(); continue; } - if (property.NameEquals("splitAllCSVs"u8)) + if (prop.NameEquals("splitAllCSVs"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - splitAllCSVs = property.Value.GetBoolean(); + splitAllCsvs = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("quickStartTest"u8)) + if (prop.NameEquals("quickStartTest"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - quickStartTest = property.Value.GetBoolean(); + quickStartTest = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("optionalLoadTestConfig"u8)) + if (prop.NameEquals("optionalLoadTestConfig"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - optionalLoadTestConfig = OptionalLoadTestConfiguration.DeserializeOptionalLoadTestConfiguration(property.Value, options); + optionalLoadTestConfiguration = OptionalLoadTestConfiguration.DeserializeOptionalLoadTestConfiguration(prop.Value, options); continue; } - if (property.NameEquals("regionalLoadTestConfig"u8)) + if (prop.NameEquals("regionalLoadTestConfig"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(RegionalConfiguration.DeserializeRegionalConfiguration(item, options)); } - regionalLoadTestConfig = array; + regionalLoadTestConfiguration = array; continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new LoadTestConfiguration( engineInstances, - splitAllCSVs, + splitAllCsvs, quickStartTest, - optionalLoadTestConfig, - regionalLoadTestConfig ?? new ChangeTrackingList(), - serializedAdditionalRawData); + optionalLoadTestConfiguration, + regionalLoadTestConfiguration ?? new ChangeTrackingList(), + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -188,15 +193,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - LoadTestConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + LoadTestConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual LoadTestConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeLoadTestConfiguration(document.RootElement, options); } default: @@ -204,22 +214,7 @@ LoadTestConfiguration IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestConfiguration.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestConfiguration.cs index 028e919c5597..56790a9e2399 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestConfiguration.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestConfiguration.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public LoadTestConfiguration() @@ -65,19 +36,20 @@ public LoadTestConfiguration() /// /// 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) + /// Keeps track of any properties unknown to the library. + internal LoadTestConfiguration(int? engineInstances, bool? splitAllCsvs, bool? quickStartTest, OptionalLoadTestConfiguration optionalLoadTestConfiguration, IList regionalLoadTestConfiguration, IDictionary additionalBinaryDataProperties) { EngineInstances = engineInstances; SplitAllCsvs = splitAllCsvs; QuickStartTest = quickStartTest; OptionalLoadTestConfiguration = optionalLoadTestConfiguration; RegionalLoadTestConfiguration = regionalLoadTestConfiguration; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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 @@ -85,13 +57,16 @@ internal LoadTestConfiguration(int? engineInstances, bool? splitAllCsvs, bool? q /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestKind.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestKind.cs index 4d7a928d4692..43d54ee8b0d5 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestKind.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestKind.cs @@ -14,41 +14,62 @@ namespace Azure.Developer.LoadTesting public readonly partial struct LoadTestKind : IEquatable { private readonly string _value; + /// URL Test. + private const string UrlValue = "URL"; + /// JMX Test. + private const string JmxValue = "JMX"; + /// Locust Test. + private const string LocustValue = "Locust"; /// Initializes a new instance of . + /// The value. /// is null. public LoadTestKind(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string UrlValue = "URL"; - private const string JmxValue = "JMX"; - private const string LocustValue = "Locust"; + _value = value; + } /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(LoadTestKind left, LoadTestKind right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(LoadTestKind left, LoadTestKind right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator LoadTestKind(string value) => new LoadTestKind(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator LoadTestKind?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestRun.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestRun.Serialization.cs index 9200744cc09e..f6c485de7e4f 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestRun.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestRun.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; namespace Azure.Developer.LoadTesting { - public partial class LoadTestRun : IUtf8JsonSerializable, IJsonModel + /// Load test run model. + public partial class LoadTestRun : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptio /// 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; + string 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); @@ -72,6 +72,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit foreach (var item in EnvironmentVariables) { writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item.Value); } writer.WriteEndObject(); @@ -80,7 +85,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("errorDetails"u8); writer.WriteStartArray(); - foreach (var item in ErrorDetails) + foreach (ErrorDetails item in ErrorDetails) { writer.WriteObjectValue(item, options); } @@ -238,15 +243,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("lastModifiedBy"u8); writer.WriteStringValue(LastModifiedBy); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -255,22 +260,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - LoadTestRun IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + LoadTestRun IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual LoadTestRun JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static LoadTestRun DeserializeLoadTestRun(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -295,14 +305,14 @@ internal static LoadTestRun DeserializeLoadTestRun(JsonElement element, ModelRea DateTimeOffset? startDateTime = default; DateTimeOffset? endDateTime = default; DateTimeOffset? executedDateTime = default; - Uri portalUrl = default; + Uri portalUri = default; long? duration = default; double? virtualUserHours = default; string subnetId = default; LoadTestKind? kind = default; RequestDataLevel? requestDataLevel = default; bool? debugLogsEnabled = default; - bool? publicIPDisabled = default; + bool? publicIpDisabled = default; CreatedByType? createdByType = default; Uri createdByUri = default; double? estimatedVirtualUserHours = default; @@ -310,328 +320,333 @@ internal static LoadTestRun DeserializeLoadTestRun(JsonElement element, ModelRea string createdBy = default; DateTimeOffset? lastModifiedDateTime = default; string lastModifiedBy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("testRunId"u8)) + if (prop.NameEquals("testRunId"u8)) { - testRunId = property.Value.GetString(); + testRunId = prop.Value.GetString(); continue; } - if (property.NameEquals("passFailCriteria"u8)) + if (prop.NameEquals("passFailCriteria"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - passFailCriteria = PassFailCriteria.DeserializePassFailCriteria(property.Value, options); + passFailCriteria = PassFailCriteria.DeserializePassFailCriteria(prop.Value, options); continue; } - if (property.NameEquals("autoStopCriteria"u8)) + if (prop.NameEquals("autoStopCriteria"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - autoStopCriteria = AutoStopCriteria.DeserializeAutoStopCriteria(property.Value, options); + autoStopCriteria = AutoStopCriteria.DeserializeAutoStopCriteria(prop.Value, options); continue; } - if (property.NameEquals("secrets"u8)) + if (prop.NameEquals("secrets"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, TestSecret.DeserializeTestSecret(property0.Value, options)); + dictionary.Add(prop0.Name, TestSecret.DeserializeTestSecret(prop0.Value, options)); } secrets = dictionary; continue; } - if (property.NameEquals("certificate"u8)) + if (prop.NameEquals("certificate"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - certificate = TestCertificate.DeserializeTestCertificate(property.Value, options); + certificate = TestCertificate.DeserializeTestCertificate(prop.Value, options); continue; } - if (property.NameEquals("environmentVariables"u8)) + if (prop.NameEquals("environmentVariables"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, property0.Value.GetString()); + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } } environmentVariables = dictionary; continue; } - if (property.NameEquals("errorDetails"u8)) + if (prop.NameEquals("errorDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(LoadTesting.ErrorDetails.DeserializeErrorDetails(item, options)); } errorDetails = array; continue; } - if (property.NameEquals("testRunStatistics"u8)) + if (prop.NameEquals("testRunStatistics"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, LoadTesting.TestRunStatistics.DeserializeTestRunStatistics(property0.Value, options)); + dictionary.Add(prop0.Name, LoadTesting.TestRunStatistics.DeserializeTestRunStatistics(prop0.Value, options)); } testRunStatistics = dictionary; continue; } - if (property.NameEquals("regionalStatistics"u8)) + if (prop.NameEquals("regionalStatistics"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, LoadTesting.TestRunStatistics.DeserializeTestRunStatistics(property0.Value, options)); + dictionary.Add(prop0.Name, LoadTesting.TestRunStatistics.DeserializeTestRunStatistics(prop0.Value, options)); } regionalStatistics = dictionary; continue; } - if (property.NameEquals("loadTestConfiguration"u8)) + if (prop.NameEquals("loadTestConfiguration"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - loadTestConfiguration = LoadTestConfiguration.DeserializeLoadTestConfiguration(property.Value, options); + loadTestConfiguration = LoadTestConfiguration.DeserializeLoadTestConfiguration(prop.Value, options); continue; } - if (property.NameEquals("testArtifacts"u8)) + if (prop.NameEquals("testArtifacts"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - testArtifacts = TestRunArtifacts.DeserializeTestRunArtifacts(property.Value, options); + testArtifacts = TestRunArtifacts.DeserializeTestRunArtifacts(prop.Value, options); continue; } - if (property.NameEquals("testResult"u8)) + if (prop.NameEquals("testResult"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - testResult = new PassFailTestResult(property.Value.GetString()); + testResult = new PassFailTestResult(prop.Value.GetString()); continue; } - if (property.NameEquals("virtualUsers"u8)) + if (prop.NameEquals("virtualUsers"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - virtualUsers = property.Value.GetInt32(); + virtualUsers = prop.Value.GetInt32(); continue; } - if (property.NameEquals("displayName"u8)) + if (prop.NameEquals("displayName"u8)) { - displayName = property.Value.GetString(); + displayName = prop.Value.GetString(); continue; } - if (property.NameEquals("testId"u8)) + if (prop.NameEquals("testId"u8)) { - testId = property.Value.GetString(); + testId = prop.Value.GetString(); continue; } - if (property.NameEquals("description"u8)) + if (prop.NameEquals("description"u8)) { - description = property.Value.GetString(); + description = prop.Value.GetString(); continue; } - if (property.NameEquals("status"u8)) + if (prop.NameEquals("status"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - status = new TestRunStatus(property.Value.GetString()); + status = new TestRunStatus(prop.Value.GetString()); continue; } - if (property.NameEquals("startDateTime"u8)) + if (prop.NameEquals("startDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - startDateTime = property.Value.GetDateTimeOffset("O"); + startDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("endDateTime"u8)) + if (prop.NameEquals("endDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - endDateTime = property.Value.GetDateTimeOffset("O"); + endDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("executedDateTime"u8)) + if (prop.NameEquals("executedDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - executedDateTime = property.Value.GetDateTimeOffset("O"); + executedDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("portalUrl"u8)) + if (prop.NameEquals("portalUrl"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - portalUrl = new Uri(property.Value.GetString()); + portalUri = new Uri(prop.Value.GetString()); continue; } - if (property.NameEquals("duration"u8)) + if (prop.NameEquals("duration"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - duration = property.Value.GetInt64(); + duration = prop.Value.GetInt64(); continue; } - if (property.NameEquals("virtualUserHours"u8)) + if (prop.NameEquals("virtualUserHours"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - virtualUserHours = property.Value.GetDouble(); + virtualUserHours = prop.Value.GetDouble(); continue; } - if (property.NameEquals("subnetId"u8)) + if (prop.NameEquals("subnetId"u8)) { - subnetId = property.Value.GetString(); + subnetId = prop.Value.GetString(); continue; } - if (property.NameEquals("kind"u8)) + if (prop.NameEquals("kind"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - kind = new LoadTestKind(property.Value.GetString()); + kind = new LoadTestKind(prop.Value.GetString()); continue; } - if (property.NameEquals("requestDataLevel"u8)) + if (prop.NameEquals("requestDataLevel"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - requestDataLevel = new RequestDataLevel(property.Value.GetString()); + requestDataLevel = new RequestDataLevel(prop.Value.GetString()); continue; } - if (property.NameEquals("debugLogsEnabled"u8)) + if (prop.NameEquals("debugLogsEnabled"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - debugLogsEnabled = property.Value.GetBoolean(); + debugLogsEnabled = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("publicIPDisabled"u8)) + if (prop.NameEquals("publicIPDisabled"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - publicIPDisabled = property.Value.GetBoolean(); + publicIpDisabled = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("createdByType"u8)) + if (prop.NameEquals("createdByType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - createdByType = new CreatedByType(property.Value.GetString()); + createdByType = new CreatedByType(prop.Value.GetString()); continue; } - if (property.NameEquals("createdByUri"u8)) + if (prop.NameEquals("createdByUri"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - createdByUri = new Uri(property.Value.GetString()); + createdByUri = new Uri(prop.Value.GetString()); continue; } - if (property.NameEquals("estimatedVirtualUserHours"u8)) + if (prop.NameEquals("estimatedVirtualUserHours"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - estimatedVirtualUserHours = property.Value.GetDouble(); + estimatedVirtualUserHours = prop.Value.GetDouble(); continue; } - if (property.NameEquals("createdDateTime"u8)) + if (prop.NameEquals("createdDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - createdDateTime = property.Value.GetDateTimeOffset("O"); + createdDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("createdBy"u8)) + if (prop.NameEquals("createdBy"u8)) { - createdBy = property.Value.GetString(); + createdBy = prop.Value.GetString(); continue; } - if (property.NameEquals("lastModifiedDateTime"u8)) + if (prop.NameEquals("lastModifiedDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + lastModifiedDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("lastModifiedBy"u8)) + if (prop.NameEquals("lastModifiedBy"u8)) { - lastModifiedBy = property.Value.GetString(); + lastModifiedBy = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new LoadTestRun( testRunId, passFailCriteria, @@ -653,14 +668,14 @@ internal static LoadTestRun DeserializeLoadTestRun(JsonElement element, ModelRea startDateTime, endDateTime, executedDateTime, - portalUrl, + portalUri, duration, virtualUserHours, subnetId, kind, requestDataLevel, debugLogsEnabled, - publicIPDisabled, + publicIpDisabled, createdByType, createdByUri, estimatedVirtualUserHours, @@ -668,13 +683,16 @@ internal static LoadTestRun DeserializeLoadTestRun(JsonElement element, ModelRea createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -684,15 +702,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options } } - LoadTestRun IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + LoadTestRun IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual LoadTestRun PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeLoadTestRun(document.RootElement, options); } default: @@ -700,22 +723,14 @@ LoadTestRun IPersistableModel.Create(BinaryData data, ModelReaderWr } } + /// The client options for reading and writing models. 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() + /// The to deserialize the from. + public static explicit operator LoadTestRun(Response response) { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); - return content; + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeLoadTestRun(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestRun.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestRun.cs index 9d58786b1e13..5f320c2892d1 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestRun.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestRun.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public LoadTestRun() @@ -105,8 +76,8 @@ public LoadTestRun() /// 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, double? estimatedVirtualUserHours, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + /// 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, double? estimatedVirtualUserHours, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary additionalBinaryDataProperties) { TestRunId = testRunId; PassFailCriteria = passFailCriteria; @@ -143,15 +114,18 @@ internal LoadTestRun(string testRunId, PassFailCriteria passFailCriteria, AutoSt CreatedBy = createdBy; LastModifiedDateTime = lastModifiedDateTime; LastModifiedBy = lastModifiedBy; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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 @@ -160,74 +134,105 @@ internal LoadTestRun(string testRunId, PassFailCriteria passFailCriteria, AutoSt /// 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; } + /// Estimated virtual user hours for the test run. public double? EstimatedVirtualUserHours { 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestRunClient.RestClient.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestRunClient.RestClient.cs new file mode 100644 index 000000000000..99a3ff4aa146 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestRunClient.RestClient.cs @@ -0,0 +1,518 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + /// + public partial class LoadTestRunClient + { + private static ResponseClassifier _pipelineMessageClassifier200; + private static ResponseClassifier _pipelineMessageClassifier200201; + private static ResponseClassifier _pipelineMessageClassifier202; + private static ResponseClassifier _pipelineMessageClassifier204; + + private static ResponseClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = new StatusCodeClassifier(stackalloc ushort[] { 200 }); + + private static ResponseClassifier PipelineMessageClassifier200201 => _pipelineMessageClassifier200201 = new StatusCodeClassifier(stackalloc ushort[] { 200, 201 }); + + private static ResponseClassifier PipelineMessageClassifier202 => _pipelineMessageClassifier202 = new StatusCodeClassifier(stackalloc ushort[] { 202 }); + + private static ResponseClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 = new StatusCodeClassifier(stackalloc ushort[] { 204 }); + + internal HttpMessage CreateCreateOrUpdateTestRunRequest(string testRunId, RequestContent content, string oldTestRunId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + 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); + } + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200201); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/merge-patch+json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateCreateOrUpdateAppComponentsRequest(string testRunId, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/app-components", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200201); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/merge-patch+json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateCreateOrUpdateServerMetricsConfigRequest(string testRunId, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/server-metrics-config", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200201); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/merge-patch+json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteTestRunRequest(string testRunId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier204); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + + internal HttpMessage CreateGetAppComponentsRequest(string testRunId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/app-components", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetServerMetricsConfigRequest(string testRunId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/server-metrics-config", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestRunRequest(string testRunId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestRunFileRequest(string testRunId, string fileName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + 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); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMetricDimensionValuesRequest(string testRunId, string name, string metricname, string metricNamespace, string timespan, string interval, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + 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("api-version", _apiVersion, true); + uri.AppendQuery("metricname", metricname, true); + if (interval != null) + { + uri.AppendQuery("interval", interval, true); + } + uri.AppendQuery("metricNamespace", metricNamespace, true); + uri.AppendQuery("timespan", timespan, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetMetricDimensionValuesRequest(Uri nextPage, string testRunId, string name, string metricname, string metricNamespace, string timespan, string interval, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMetricDefinitionsRequest(string testRunId, string metricNamespace, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/metric-definitions", false); + uri.AppendQuery("api-version", _apiVersion, true); + uri.AppendQuery("metricNamespace", metricNamespace, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMetricNamespacesRequest(string testRunId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/metric-namespaces", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMetricsRequest(string testRunId, string metricname, string metricNamespace, string timespan, RequestContent content, string aggregation, string interval, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/metrics", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (aggregation != null) + { + uri.AppendQuery("aggregation", aggregation, true); + } + uri.AppendQuery("metricname", metricname, true); + if (interval != null) + { + uri.AppendQuery("interval", interval, true); + } + uri.AppendQuery("metricNamespace", metricNamespace, true); + uri.AppendQuery("timespan", timespan, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + if ("application/json" != null) + { + request.Headers.SetValue("Content-Type", "application/json"); + } + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateNextGetMetricsRequest(Uri nextPage, string testRunId, string metricname, string metricNamespace, string timespan, RequestContent content, string aggregation, string interval, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestRunsRequest(string @orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, int? maxpagesize, IEnumerable createdByTypes, IEnumerable testIds, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + 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", TypeFormatters.ConvertToString(executionFrom, SerializationFormat.DateTime_RFC3339), true); + } + if (executionTo != null) + { + uri.AppendQuery("executionTo", TypeFormatters.ConvertToString(executionTo, SerializationFormat.DateTime_RFC3339), true); + } + if (status != null) + { + uri.AppendQuery("status", status, true); + } + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", TypeFormatters.ConvertToString(maxpagesize), true); + } + if (createdByTypes != null && !(createdByTypes is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) + { + uri.AppendQueryDelimited("createdByTypes", createdByTypes, ",", escape: true); + } + if (testIds != null && !(testIds is ChangeTrackingList changeTrackingList0 && changeTrackingList0.IsUndefined)) + { + uri.AppendQueryDelimited("testIds", testIds, ",", escape: true); + } + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetTestRunsRequest(Uri nextPage, string @orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, int? maxpagesize, IEnumerable createdByTypes, IEnumerable testIds, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateStopTestRunRequest(string testRunId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath(":stop", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateTestProfileRunRequest(string testProfileRunId, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-profile-runs/", false); + uri.AppendPath(testProfileRunId, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200201); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/merge-patch+json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteTestProfileRunRequest(string testProfileRunId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-profile-runs/", false); + uri.AppendPath(testProfileRunId, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier204); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + + internal HttpMessage CreateGetTestProfileRunRequest(string testProfileRunId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-profile-runs/", false); + uri.AppendPath(testProfileRunId, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("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) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-profile-runs", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", TypeFormatters.ConvertToString(maxpagesize), true); + } + if (minStartDateTime != null) + { + uri.AppendQuery("minStartDateTime", TypeFormatters.ConvertToString(minStartDateTime, SerializationFormat.DateTime_RFC3339), true); + } + if (maxStartDateTime != null) + { + uri.AppendQuery("maxStartDateTime", TypeFormatters.ConvertToString(maxStartDateTime, SerializationFormat.DateTime_RFC3339), true); + } + if (minEndDateTime != null) + { + uri.AppendQuery("minEndDateTime", TypeFormatters.ConvertToString(minEndDateTime, SerializationFormat.DateTime_RFC3339), true); + } + if (maxEndDateTime != null) + { + uri.AppendQuery("maxEndDateTime", TypeFormatters.ConvertToString(maxEndDateTime, SerializationFormat.DateTime_RFC3339), true); + } + if (createdDateStartTime != null) + { + uri.AppendQuery("createdDateStartTime", TypeFormatters.ConvertToString(createdDateStartTime, SerializationFormat.DateTime_RFC3339), true); + } + if (createdDateEndTime != null) + { + uri.AppendQuery("createdDateEndTime", TypeFormatters.ConvertToString(createdDateEndTime, SerializationFormat.DateTime_RFC3339), true); + } + if (testProfileRunIds != null && !(testProfileRunIds is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) + { + uri.AppendQueryDelimited("testProfileRunIds", testProfileRunIds, ",", escape: true); + } + if (testProfileIds != null && !(testProfileIds is ChangeTrackingList changeTrackingList0 && changeTrackingList0.IsUndefined)) + { + uri.AppendQueryDelimited("testProfileIds", testProfileIds, ",", escape: true); + } + if (statuses != null && !(statuses is ChangeTrackingList changeTrackingList1 && changeTrackingList1.IsUndefined)) + { + uri.AppendQueryDelimited("statuses", statuses, ",", escape: true); + } + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetTestProfileRunsRequest(Uri nextPage, int? maxpagesize, DateTimeOffset? minStartDateTime, DateTimeOffset? maxStartDateTime, DateTimeOffset? minEndDateTime, DateTimeOffset? maxEndDateTime, DateTimeOffset? createdDateStartTime, DateTimeOffset? createdDateEndTime, IEnumerable testProfileRunIds, IEnumerable testProfileIds, IEnumerable statuses, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateStopTestProfileRunRequest(string testProfileRunId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-profile-runs/", false); + uri.AppendPath(testProfileRunId, true); + uri.AppendPath(":stop", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetLatestTestRunInsightsRequest(string testRunId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/insights/latest", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier200); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGenerateTestRunInsightsRequest(string testRunId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/insights:generate", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(context, PipelineMessageClassifier202); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestRunClient.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestRunClient.cs index 1951b42d6557..2efd0582b0d2 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestRunClient.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestRunClient.cs @@ -9,66 +9,66 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; namespace Azure.Developer.LoadTesting { - // Data plane generated client. - /// The LoadTestRun service client. + /// The LoadTestRunClient. 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; + /// A credential used to authenticate to the service. + private readonly TokenCredential _tokenCredential; + private static readonly string[] AuthorizationScopes = new string[] { "https://cnt-prod.loadtesting.azure.com/.default" }; 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. + /// + /// A credential used to authenticate to the service. /// or is null. - public LoadTestRunClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new LoadTestingClientOptions()) + /// is an empty string, and was expected to be non-empty. + public LoadTestRunClient(string endpoint, TokenCredential credential) : this(endpoint, credential, new LoadTestingClientOptions()) { } /// Initializes a new instance of LoadTestRunClient. - /// The to use. - /// A credential used to authenticate to an Azure Service. + /// + /// A credential used to authenticate to the service. /// The options for configuring the client. /// or is null. - public LoadTestRunClient(Uri endpoint, TokenCredential credential, LoadTestingClientOptions options) + /// is an empty string, and was expected to be non-empty. + public LoadTestRunClient(string endpoint, TokenCredential credential, LoadTestingClientOptions options) { - Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNullOrEmpty(endpoint, nameof(endpoint)); Argument.AssertNotNull(credential, nameof(credential)); + options ??= new LoadTestingClientOptions(); - ClientDiagnostics = new ClientDiagnostics(options, true); + _endpoint = new Uri($"https://{endpoint}"); _tokenCredential = credential; - _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier()); - _endpoint = endpoint; + Pipeline = HttpPipelineBuilder.Build(options, new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }); _apiVersion = options.Version; + ClientDiagnostics = new ClientDiagnostics(options, true); } + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + /// /// [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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -80,22 +80,17 @@ public LoadTestRunClient(Uri endpoint, TokenCredential credential, LoadTestingCl /// 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. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task CreateOrUpdateTestRunAsync(string testRunId, RequestContent content, string oldTestRunId = null, RequestContext context = null) + internal virtual Response CreateOrUpdateTestRun(string testRunId, RequestContent content, string oldTestRunId = default, RequestContext context = null) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateTestRun"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateTestRun"); scope.Start(); try { using HttpMessage message = CreateCreateOrUpdateTestRunRequest(testRunId, content, oldTestRunId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -108,9 +103,7 @@ internal virtual async Task CreateOrUpdateTestRunAsync(string testRunI /// [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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -122,22 +115,17 @@ internal virtual async Task CreateOrUpdateTestRunAsync(string testRunI /// 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. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response CreateOrUpdateTestRun(string testRunId, RequestContent content, string oldTestRunId = null, RequestContext context = null) + internal virtual async Task CreateOrUpdateTestRunAsync(string testRunId, RequestContent content, string oldTestRunId = default, RequestContext context = null) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateTestRun"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateTestRun"); scope.Start(); try { using HttpMessage message = CreateCreateOrUpdateTestRunRequest(testRunId, content, oldTestRunId, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -147,12 +135,10 @@ internal virtual Response CreateOrUpdateTestRun(string testRunId, RequestContent } /// - /// [Protocol Method] Add an app component to a test run. + /// [Protocol Method] Add an app component to a test run by providing the resource Id, name and type. /// /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -161,22 +147,22 @@ internal virtual Response CreateOrUpdateTestRun(string testRunId, RequestContent /// 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. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateAppComponents"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(content, nameof(content)); + using HttpMessage message = CreateCreateOrUpdateAppComponentsRequest(testRunId, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -186,12 +172,10 @@ public virtual async Task CreateOrUpdateAppComponentsAsync(string test } /// - /// [Protocol Method] Add an app component to a test run. + /// [Protocol Method] Add an app component to a test run by providing the resource Id, name and type. /// /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -200,22 +184,22 @@ public virtual async Task CreateOrUpdateAppComponentsAsync(string test /// 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. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateAppComponents"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(content, nameof(content)); + using HttpMessage message = CreateCreateOrUpdateAppComponentsRequest(testRunId, content, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -228,9 +212,7 @@ public virtual Response CreateOrUpdateAppComponents(string testRunId, RequestCon /// [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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -239,22 +221,22 @@ public virtual Response CreateOrUpdateAppComponents(string testRunId, RequestCon /// 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. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateServerMetricsConfig"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(content, nameof(content)); + using HttpMessage message = CreateCreateOrUpdateServerMetricsConfigRequest(testRunId, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -267,9 +249,7 @@ public virtual async Task CreateOrUpdateServerMetricsConfigAsync(strin /// [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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -278,22 +258,22 @@ public virtual async Task CreateOrUpdateServerMetricsConfigAsync(strin /// 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. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateServerMetricsConfig"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(content, nameof(content)); + using HttpMessage message = CreateCreateOrUpdateServerMetricsConfigRequest(testRunId, content, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -302,33 +282,30 @@ public virtual Response CreateOrUpdateServerMetricsConfig(string testRunId, Requ } } - // 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. + /// [Protocol Method] Delete an existing load test run by providing the testRunId. /// /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// + /// 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. + /// The request options, 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) + public virtual Response DeleteTestRun(string testRunId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.DeleteTestRun"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.DeleteTestRun"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + using HttpMessage message = CreateDeleteTestRunRequest(testRunId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -337,33 +314,30 @@ public virtual async Task DeleteTestRunAsync(string testRunId, Request } } - // 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. + /// [Protocol Method] Delete an existing load test run by providing the testRunId. /// /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// + /// 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. + /// The request options, 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) + public virtual async Task DeleteTestRunAsync(string testRunId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.DeleteTestRun"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.DeleteTestRun"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + using HttpMessage message = CreateDeleteTestRunRequest(testRunId, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -372,44 +346,30 @@ public virtual Response DeleteTestRun(string testRunId, RequestContext context = } } - /// - /// 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. + /// Delete an existing load test run by providing the testRunId. + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token that can be used to cancel the operation. /// is null. /// is an empty string, and was expected to be non-empty. - public virtual async Task> GetAppComponentsAsync(string testRunId, CancellationToken cancellationToken = default) + /// Service returned a non-success status code. + public virtual Response DeleteTestRun(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); + return DeleteTestRun(testRunId, cancellationToken.ToRequestContext()); } - /// - /// 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. + /// Delete an existing load test run by providing the testRunId. + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token that can be used to cancel the operation. /// is null. /// is an empty string, and was expected to be non-empty. - public virtual Response GetAppComponents(string testRunId, CancellationToken cancellationToken = default) + /// Service returned a non-success status code. + public virtual async Task DeleteTestRunAsync(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); + return await DeleteTestRunAsync(testRunId, cancellationToken.ToRequestContext()).ConfigureAwait(false); } /// @@ -417,14 +377,7 @@ public virtual Response GetAppComponents(string testRunId, /// 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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -432,21 +385,21 @@ public virtual Response GetAppComponents(string testRunId, /// 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. + /// The request options, 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) + public virtual Response GetAppComponents(string testRunId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetAppComponents"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetAppComponents"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + using HttpMessage message = CreateGetAppComponentsRequest(testRunId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -460,14 +413,7 @@ public virtual async Task GetAppComponentsAsync(string testRunId, Requ /// 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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -475,21 +421,21 @@ public virtual async Task GetAppComponentsAsync(string testRunId, Requ /// 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. + /// The request options, 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) + public virtual async Task GetAppComponentsAsync(string testRunId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetAppComponents"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetAppComponents"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + using HttpMessage message = CreateGetAppComponentsRequest(testRunId, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -498,52 +444,51 @@ public virtual Response GetAppComponents(string testRunId, RequestContext contex } } - /// Get associated server metrics configuration for the given test run. + /// + /// 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. + /// The cancellation token that can be used to cancel the operation. /// is null. /// is an empty string, and was expected to be non-empty. - public virtual async Task> GetServerMetricsConfigAsync(string testRunId, CancellationToken cancellationToken = default) + /// Service returned a non-success status code. + public virtual Response GetAppComponents(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); + Response result = GetAppComponents(testRunId, cancellationToken.ToRequestContext()); + return Response.FromValue((TestRunAppComponents)result, result); } - /// Get associated server metrics configuration for the given test run. + /// + /// 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. + /// The cancellation token that can be used to cancel the operation. /// is null. /// is an empty string, and was expected to be non-empty. - public virtual Response GetServerMetricsConfig(string testRunId, CancellationToken cancellationToken = default) + /// Service returned a non-success status code. + public virtual async Task> GetAppComponentsAsync(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); + Response result = await GetAppComponentsAsync(testRunId, cancellationToken.ToRequestContext()).ConfigureAwait(false); + return Response.FromValue((TestRunAppComponents)result, result); } /// /// [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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -551,21 +496,21 @@ public virtual Response GetServerMetricsConfi /// 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. + /// The request options, 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) + public virtual Response GetServerMetricsConfig(string testRunId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetServerMetricsConfig"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetServerMetricsConfig"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + using HttpMessage message = CreateGetServerMetricsConfigRequest(testRunId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -578,14 +523,7 @@ public virtual async Task GetServerMetricsConfigAsync(string testRunId /// [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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -593,21 +531,21 @@ public virtual async Task GetServerMetricsConfigAsync(string testRunId /// 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. + /// The request options, 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) + public virtual async Task GetServerMetricsConfigAsync(string testRunId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetServerMetricsConfig"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetServerMetricsConfig"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + using HttpMessage message = CreateGetServerMetricsConfigRequest(testRunId, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -616,65 +554,64 @@ public virtual Response GetServerMetricsConfig(string testRunId, RequestContext } } - /// 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. + /// 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 that can be used to cancel the operation. /// is null. /// is an empty string, and was expected to be non-empty. - public virtual async Task> GetTestRunAsync(string testRunId, CancellationToken cancellationToken = default) + /// Service returned a non-success status code. + public virtual Response GetServerMetricsConfig(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); + Response result = GetServerMetricsConfig(testRunId, cancellationToken.ToRequestContext()); + return Response.FromValue((TestRunServerMetricsConfiguration)result, result); } - /// 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. + /// 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 that can be used to cancel the operation. /// is null. /// is an empty string, and was expected to be non-empty. - public virtual Response GetTestRun(string testRunId, CancellationToken cancellationToken = default) + /// Service returned a non-success status code. + public virtual async Task> GetServerMetricsConfigAsync(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); + Response result = await GetServerMetricsConfigAsync(testRunId, cancellationToken.ToRequestContext()).ConfigureAwait(false); + return Response.FromValue((TestRunServerMetricsConfiguration)result, result); } /// /// [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. - /// + /// 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. + /// The request options, 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) + public virtual Response GetTestRun(string testRunId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRun"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRun"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + using HttpMessage message = CreateGetTestRunRequest(testRunId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -687,33 +624,26 @@ public virtual async Task GetTestRunAsync(string testRunId, RequestCon /// [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. - /// + /// 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. + /// The request options, 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) + public virtual async Task GetTestRunAsync(string testRunId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRun"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRun"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + using HttpMessage message = CreateGetTestRunRequest(testRunId, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -722,71 +652,60 @@ public virtual Response GetTestRun(string testRunId, RequestContext context) } } - /// Get test run file by file name. + /// 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. - /// 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) + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual Response GetTestRun(string testRunId, 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); + Response result = GetTestRun(testRunId, cancellationToken.ToRequestContext()); + return Response.FromValue((LoadTestRun)result, result); } - /// Get test run file by file name. + /// 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. - /// 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) + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetTestRunAsync(string testRunId, 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); + Response result = await GetTestRunAsync(testRunId, cancellationToken.ToRequestContext()).ConfigureAwait(false); + return Response.FromValue((LoadTestRun)result, result); } /// /// [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. - /// + /// 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. /// Name of the file. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRunFile"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + using HttpMessage message = CreateGetTestRunFileRequest(testRunId, fileName, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -799,35 +718,28 @@ public virtual async Task GetTestRunFileAsync(string testRunId, string /// [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. - /// + /// 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. /// Name of the file. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// The request options, 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) + 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"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRunFile"); scope.Start(); try { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + using HttpMessage message = CreateGetTestRunFileRequest(testRunId, fileName, context); - return _pipeline.ProcessMessage(message, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -836,56 +748,43 @@ public virtual Response GetTestRunFile(string testRunId, string fileName, Reques } } - /// 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) + /// 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 that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual Response GetTestRunFile(string testRunId, string fileName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetMetricDefinitionsAsync(testRunId, metricNamespace, context).ConfigureAwait(false); - return Response.FromValue(MetricDefinitions.FromResponse(response), response); + Response result = GetTestRunFile(testRunId, fileName, cancellationToken.ToRequestContext()); + return Response.FromValue((TestRunFileInfo)result, result); } - /// 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) + /// 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 that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetTestRunFileAsync(string testRunId, string fileName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetMetricDefinitions(testRunId, metricNamespace, context); - return Response.FromValue(MetricDefinitions.FromResponse(response), response); + Response result = await GetTestRunFileAsync(testRunId, fileName, cancellationToken.ToRequestContext()).ConfigureAwait(false); + return Response.FromValue((TestRunFileInfo)result, result); } /// - /// [Protocol Method] List the metric definitions for a load test run. + /// [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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -893,23 +792,37 @@ public virtual Response GetMetricDefinitions(string testRunId /// 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 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. + /// 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 request options, 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 GetMetricDefinitionsAsync(string testRunId, string metricNamespace, RequestContext context) + public virtual Pageable GetMetricDimensionValues(string testRunId, string name, string metricname, string metricNamespace, string timespan, string interval, RequestContext context) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricDefinitions"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricDimensionValues"); scope.Start(); try { - using HttpMessage message = CreateGetMetricDefinitionsRequest(testRunId, metricNamespace, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(metricname, nameof(metricname)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNullOrEmpty(timespan, nameof(timespan)); + + return new LoadTestRunClientGetMetricDimensionValuesCollectionResult( + this, + testRunId, + name, + metricname, + metricNamespace, + timespan, + interval, + context); } catch (Exception e) { @@ -919,17 +832,10 @@ public virtual async Task GetMetricDefinitionsAsync(string testRunId, } /// - /// [Protocol Method] List the metric definitions for a load test run. + /// [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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -937,23 +843,37 @@ public virtual async Task GetMetricDefinitionsAsync(string testRunId, /// 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 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. + /// 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 request options, 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 GetMetricDefinitions(string testRunId, string metricNamespace, RequestContext context) + public virtual AsyncPageable GetMetricDimensionValuesAsync(string testRunId, string name, string metricname, string metricNamespace, string timespan, string interval, RequestContext context) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricDefinitions"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricDimensionValues"); scope.Start(); try { - using HttpMessage message = CreateGetMetricDefinitionsRequest(testRunId, metricNamespace, context); - return _pipeline.ProcessMessage(message, context); + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(metricname, nameof(metricname)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNullOrEmpty(timespan, nameof(timespan)); + + return new LoadTestRunClientGetMetricDimensionValuesAsyncCollectionResult( + this, + testRunId, + name, + metricname, + metricNamespace, + timespan, + interval, + context); } catch (Exception e) { @@ -962,52 +882,77 @@ public virtual Response GetMetricDefinitions(string testRunId, string metricName } } - /// List the metric namespaces for a load test run. + /// 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. /// - /// 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) + /// 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 that can be used to cancel the operation. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual Pageable GetMetricDimensionValues(string testRunId, string name, string metricname, string metricNamespace, string timespan, TimeGrain? interval = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(metricname, nameof(metricname)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNullOrEmpty(timespan, nameof(timespan)); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetMetricNamespacesAsync(testRunId, context).ConfigureAwait(false); - return Response.FromValue(MetricNamespaces.FromResponse(response), response); + return new LoadTestRunClientGetMetricDimensionValuesCollectionResultOfT( + this, + testRunId, + name, + metricname, + metricNamespace, + timespan, + interval?.ToString(), + cancellationToken.ToRequestContext()); } - /// List the metric namespaces for a load test run. + /// 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. /// - /// 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) + /// 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 that can be used to cancel the operation. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual AsyncPageable GetMetricDimensionValuesAsync(string testRunId, string name, string metricname, string metricNamespace, string timespan, TimeGrain? interval = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(metricname, nameof(metricname)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNullOrEmpty(timespan, nameof(timespan)); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetMetricNamespaces(testRunId, context); - return Response.FromValue(MetricNamespaces.FromResponse(response), response); + return new LoadTestRunClientGetMetricDimensionValuesAsyncCollectionResultOfT( + this, + testRunId, + name, + metricname, + metricNamespace, + timespan, + interval?.ToString(), + cancellationToken.ToRequestContext()); } /// - /// [Protocol Method] List the metric namespaces for a load test run. + /// [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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -1015,21 +960,23 @@ public virtual Response GetMetricNamespaces(string testRunId, /// 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. + /// Metric namespace to query metric definitions for. + /// The request options, 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 GetMetricNamespacesAsync(string testRunId, RequestContext context) + public virtual Response GetMetricDefinitions(string testRunId, string metricNamespace, RequestContext context) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricNamespaces"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricDefinitions"); scope.Start(); try { - using HttpMessage message = CreateGetMetricNamespacesRequest(testRunId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); + + using HttpMessage message = CreateGetMetricDefinitionsRequest(testRunId, metricNamespace, context); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -1039,17 +986,10 @@ public virtual async Task GetMetricNamespacesAsync(string testRunId, R } /// - /// [Protocol Method] List the metric namespaces for a load test run. + /// [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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// @@ -1057,21 +997,23 @@ public virtual async Task GetMetricNamespacesAsync(string testRunId, R /// 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. + /// Metric namespace to query metric definitions for. + /// The request options, 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 GetMetricNamespaces(string testRunId, RequestContext context) + public virtual async Task GetMetricDefinitionsAsync(string testRunId, string metricNamespace, RequestContext context) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricNamespaces"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricDefinitions"); scope.Start(); try { - using HttpMessage message = CreateGetMetricNamespacesRequest(testRunId, context); - return _pipeline.ProcessMessage(message, context); + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); + + using HttpMessage message = CreateGetMetricDefinitionsRequest(testRunId, metricNamespace, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -1080,65 +1022,71 @@ public virtual Response GetMetricNamespaces(string testRunId, RequestContext con } } - /// 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) + /// 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 that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual Response GetMetricDefinitions(string testRunId, string metricNamespace, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await StopTestRunAsync(testRunId, context).ConfigureAwait(false); - return Response.FromValue(LoadTestRun.FromResponse(response), response); + Response result = GetMetricDefinitions(testRunId, metricNamespace, cancellationToken.ToRequestContext()); + return Response.FromValue((MetricDefinitions)result, result); } - /// 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) + /// 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 that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetMetricDefinitionsAsync(string testRunId, string metricNamespace, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = StopTestRun(testRunId, context); - return Response.FromValue(LoadTestRun.FromResponse(response), response); + Response result = await GetMetricDefinitionsAsync(testRunId, metricNamespace, cancellationToken.ToRequestContext()).ConfigureAwait(false); + return Response.FromValue((MetricDefinitions)result, result); } /// - /// [Protocol Method] Stop test run by test run Id. + /// [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. - /// + /// 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. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The request options, 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) + public virtual Response GetMetricNamespaces(string testRunId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.StopTestRun"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricNamespaces"); scope.Start(); try { - using HttpMessage message = CreateStopTestRunRequest(testRunId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using HttpMessage message = CreateGetMetricNamespacesRequest(testRunId, context); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -1148,36 +1096,32 @@ public virtual async Task StopTestRunAsync(string testRunId, RequestCo } /// - /// [Protocol Method] Stop test run by test run Id. + /// [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. - /// + /// 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. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The request options, 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) + public virtual async Task GetMetricNamespacesAsync(string testRunId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.StopTestRun"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricNamespaces"); scope.Start(); try { - using HttpMessage message = CreateStopTestRunRequest(testRunId, context); - return _pipeline.ProcessMessage(message, context); + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using HttpMessage message = CreateGetMetricNamespacesRequest(testRunId, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -1186,34 +1130,84 @@ public virtual Response StopTestRun(string testRunId, RequestContext context) } } + /// 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 that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual Response GetMetricNamespaces(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + Response result = GetMetricNamespaces(testRunId, cancellationToken.ToRequestContext()); + return Response.FromValue((MetricNamespaces)result, result); + } + + /// 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 that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetMetricNamespacesAsync(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + Response result = await GetMetricNamespacesAsync(testRunId, cancellationToken.ToRequestContext()).ConfigureAwait(false); + return Response.FromValue((MetricNamespaces)result, result); + } + /// - /// [Protocol Method] Create and start a new test profile run. + /// [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. - /// + /// 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. + /// + /// 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 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. + /// The aggregation. + /// The interval (i.e. timegrain) of the query. + /// The request options, 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 CreateOrUpdateTestProfileRunAsync(string testProfileRunId, RequestContent content, RequestContext context = null) + public virtual Pageable GetMetrics(string testRunId, string metricname, string metricNamespace, string timespan, RequestContent content, string aggregation = default, string interval = default, RequestContext context = null) { - Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateTestProfileRun"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetrics"); scope.Start(); try { - using HttpMessage message = CreateCreateOrUpdateTestProfileRunRequest(testProfileRunId, content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(metricname, nameof(metricname)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNullOrEmpty(timespan, nameof(timespan)); + + return new LoadTestRunClientGetMetricsCollectionResult( + this, + testRunId, + metricname, + metricNamespace, + timespan, + content, + aggregation, + interval, + context); } catch (Exception e) { @@ -1223,33 +1217,49 @@ internal virtual async Task CreateOrUpdateTestProfileRunAsync(string t } /// - /// [Protocol Method] Create and start a new test profile run. + /// [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. - /// + /// 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. + /// + /// 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 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. + /// The aggregation. + /// The interval (i.e. timegrain) of the query. + /// The request options, 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 CreateOrUpdateTestProfileRun(string testProfileRunId, RequestContent content, RequestContext context = null) + public virtual AsyncPageable GetMetricsAsync(string testRunId, string metricname, string metricNamespace, string timespan, RequestContent content, string aggregation = default, string interval = default, RequestContext context = null) { - Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateTestProfileRun"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetrics"); scope.Start(); try { - using HttpMessage message = CreateCreateOrUpdateTestProfileRunRequest(testProfileRunId, content, context); - return _pipeline.ProcessMessage(message, context); + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(metricname, nameof(metricname)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNullOrEmpty(timespan, nameof(timespan)); + + return new LoadTestRunClientGetMetricsAsyncCollectionResult( + this, + testRunId, + metricname, + metricNamespace, + timespan, + content, + aggregation, + interval, + context); } catch (Exception e) { @@ -1258,33 +1268,119 @@ internal virtual Response CreateOrUpdateTestProfileRun(string testProfileRunId, } } - // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// 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 that can be used to cancel the operation. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual Pageable GetMetrics(string testRunId, string metricname, string metricNamespace, string timespan, MetricsFilters body = default, string aggregation = default, TimeGrain? interval = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(metricname, nameof(metricname)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNullOrEmpty(timespan, nameof(timespan)); + + return new LoadTestRunClientGetMetricsCollectionResultOfT( + this, + testRunId, + metricname, + metricNamespace, + timespan, + body, + aggregation, + interval?.ToString(), + cancellationToken.ToRequestContext()); + } + + /// 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 that can be used to cancel the operation. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual AsyncPageable GetMetricsAsync(string testRunId, string metricname, string metricNamespace, string timespan, MetricsFilters body = default, string aggregation = default, TimeGrain? interval = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(metricname, nameof(metricname)); + Argument.AssertNotNullOrEmpty(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNullOrEmpty(timespan, nameof(timespan)); + + return new LoadTestRunClientGetMetricsAsyncCollectionResultOfT( + this, + testRunId, + metricname, + metricNamespace, + timespan, + body, + aggregation, + interval?.ToString(), + cancellationToken.ToRequestContext()); + } + /// - /// [Protocol Method] Delete an existing load test profile run. + /// [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. - /// + /// 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. + /// + /// 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. + /// Comma-separated list of test IDs. If you are using testIds, do not send a value for testId. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. /// Service returned a non-success status code. /// The response returned from the service. - public virtual async Task DeleteTestProfileRunAsync(string testProfileRunId, RequestContext context = null) + public virtual Pageable GetTestRuns(string @orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, int? maxpagesize, IEnumerable createdByTypes, IEnumerable testIds, RequestContext context) { - Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.DeleteTestProfileRun"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRuns"); scope.Start(); try { - using HttpMessage message = CreateDeleteTestProfileRunRequest(testProfileRunId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return new LoadTestRunClientGetTestRunsCollectionResult( + this, + @orderby, + search, + testId, + executionFrom, + executionTo, + status, + maxpagesize, + createdByTypes, + testIds, + context); } catch (Exception e) { @@ -1293,33 +1389,51 @@ public virtual async Task DeleteTestProfileRunAsync(string testProfile } } - // 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. + /// [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. - /// + /// 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. + /// + /// 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. + /// Comma-separated list of test IDs. If you are using testIds, do not send a value for testId. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. /// Service returned a non-success status code. /// The response returned from the service. - public virtual Response DeleteTestProfileRun(string testProfileRunId, RequestContext context = null) + public virtual AsyncPageable GetTestRunsAsync(string @orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, int? maxpagesize, IEnumerable createdByTypes, IEnumerable testIds, RequestContext context) { - Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.DeleteTestProfileRun"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRuns"); scope.Start(); try { - using HttpMessage message = CreateDeleteTestProfileRunRequest(testProfileRunId, context); - return _pipeline.ProcessMessage(message, context); + return new LoadTestRunClientGetTestRunsAsyncCollectionResult( + this, + @orderby, + search, + testId, + executionFrom, + executionTo, + status, + maxpagesize, + createdByTypes, + testIds, + context); } catch (Exception e) { @@ -1328,67 +1442,189 @@ public virtual Response DeleteTestProfileRun(string testProfileRunId, RequestCon } } - /// 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)); + /// 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. + /// Comma-separated list of test IDs. If you are using testIds, do not send a value for testId. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual Pageable GetTestRuns(string @orderby = default, string search = default, string testId = default, DateTimeOffset? executionFrom = default, DateTimeOffset? executionTo = default, string status = default, int? maxpagesize = default, IEnumerable createdByTypes = default, IEnumerable testIds = default, CancellationToken cancellationToken = default) + { + return new LoadTestRunClientGetTestRunsCollectionResultOfT( + this, + @orderby, + search, + testId, + executionFrom, + executionTo, + status, + maxpagesize, + createdByTypes, + testIds, + cancellationToken.ToRequestContext()); + } - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetTestProfileRunAsync(testProfileRunId, context).ConfigureAwait(false); - return Response.FromValue(TestProfileRun.FromResponse(response), response); + /// 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. + /// Comma-separated list of test IDs. If you are using testIds, do not send a value for testId. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual AsyncPageable GetTestRunsAsync(string @orderby = default, string search = default, string testId = default, DateTimeOffset? executionFrom = default, DateTimeOffset? executionTo = default, string status = default, int? maxpagesize = default, IEnumerable createdByTypes = default, IEnumerable testIds = default, CancellationToken cancellationToken = default) + { + return new LoadTestRunClientGetTestRunsAsyncCollectionResultOfT( + this, + @orderby, + search, + testId, + executionFrom, + executionTo, + status, + maxpagesize, + createdByTypes, + testIds, + cancellationToken.ToRequestContext()); } - /// 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) + /// + /// [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. + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request options, 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(testProfileRunId, nameof(testProfileRunId)); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.StopTestRun"); + scope.Start(); + try + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetTestProfileRun(testProfileRunId, context); - return Response.FromValue(TestProfileRun.FromResponse(response), response); + using HttpMessage message = CreateStopTestRunRequest(testRunId, context); + return Pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// - /// [Protocol Method] Get test profile run details. + /// [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. - /// + /// 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 options, 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) + { + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.StopTestRun"); + scope.Start(); + try + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using HttpMessage message = CreateStopTestRunRequest(testRunId, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + 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 that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual Response StopTestRun(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + Response result = StopTestRun(testRunId, cancellationToken.ToRequestContext()); + return Response.FromValue((LoadTestRun)result, result); + } + + /// 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 that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> StopTestRunAsync(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + Response result = await StopTestRunAsync(testRunId, cancellationToken.ToRequestContext()).ConfigureAwait(false); + return Response.FromValue((LoadTestRun)result, result); + } + + /// + /// [Protocol Method] Create and start a new test profile run with the given test profile run Id. + /// /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// + /// 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. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. /// Service returned a non-success status code. /// The response returned from the service. - public virtual async Task GetTestProfileRunAsync(string testProfileRunId, RequestContext context) + internal virtual Response CreateOrUpdateTestProfileRun(string testProfileRunId, RequestContent content, RequestContext context = null) { - Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestProfileRun"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateTestProfileRun"); scope.Start(); try { - using HttpMessage message = CreateGetTestProfileRunRequest(testProfileRunId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + using HttpMessage message = CreateCreateOrUpdateTestProfileRunRequest(testProfileRunId, content, context); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -1398,36 +1634,90 @@ public virtual async Task GetTestProfileRunAsync(string testProfileRun } /// - /// [Protocol Method] Get test profile run details. + /// [Protocol Method] Create and start a new test profile run with the given test profile run Id. /// /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual async Task CreateOrUpdateTestProfileRunAsync(string testProfileRunId, RequestContent content, RequestContext context = null) + { + using DiagnosticScope 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] Delete an existing load test profile run by providing the test profile run Id. + /// /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// + /// 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. + /// The request options, 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) + public virtual Response DeleteTestProfileRun(string testProfileRunId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.DeleteTestProfileRun"); + scope.Start(); + try + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + using HttpMessage message = CreateDeleteTestProfileRunRequest(testProfileRunId, context); + return Pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestProfileRun"); + /// + /// [Protocol Method] Delete an existing load test profile run by providing the test profile run Id. + /// + /// + /// 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 options, 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) + { + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.DeleteTestProfileRun"); scope.Start(); try { - using HttpMessage message = CreateGetTestProfileRunRequest(testProfileRunId, context); - return _pipeline.ProcessMessage(message, context); + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + using HttpMessage message = CreateDeleteTestProfileRunRequest(testProfileRunId, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -1436,67 +1726,56 @@ public virtual Response GetTestProfileRun(string testProfileRunId, RequestContex } } - /// Stop test profile run. + /// Delete an existing load test profile run by providing the test profile run Id. /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. - /// The cancellation token to use. + /// The cancellation token that can be used to cancel the operation. /// 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) + /// Service returned a non-success status code. + public virtual Response DeleteTestProfileRun(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); + return DeleteTestProfileRun(testProfileRunId, cancellationToken.ToRequestContext()); } - /// Stop test profile run. + /// Delete an existing load test profile run by providing the test profile run Id. /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. - /// The cancellation token to use. + /// The cancellation token that can be used to cancel the operation. /// 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) + /// Service returned a non-success status code. + public virtual async Task DeleteTestProfileRunAsync(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); + return await DeleteTestProfileRunAsync(testProfileRunId, cancellationToken.ToRequestContext()).ConfigureAwait(false); } /// - /// [Protocol Method] Stop test profile run. + /// [Protocol Method] Get test profile run details by test profile 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. - /// + /// 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. + /// The request options, 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) + public virtual Response GetTestProfileRun(string testProfileRunId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.StopTestProfileRun"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestProfileRun"); scope.Start(); try { - using HttpMessage message = CreateStopTestProfileRunRequest(testProfileRunId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + using HttpMessage message = CreateGetTestProfileRunRequest(testProfileRunId, context); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -1506,36 +1785,29 @@ public virtual async Task StopTestProfileRunAsync(string testProfileRu } /// - /// [Protocol Method] Stop test profile run. + /// [Protocol Method] Get test profile run details by test profile 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. - /// + /// 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. + /// The request options, 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) + public virtual async Task GetTestProfileRunAsync(string testProfileRunId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.StopTestProfileRun"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestProfileRun"); scope.Start(); try { - using HttpMessage message = CreateStopTestProfileRunRequest(testProfileRunId, context); - return _pipeline.ProcessMessage(message, context); + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + using HttpMessage message = CreateGetTestProfileRunRequest(testProfileRunId, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -1544,74 +1816,74 @@ public virtual Response StopTestProfileRun(string testProfileRunId, RequestConte } } - /// Get the latest insights for the 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> GetLatestTestRunInsightsAsync(string testRunId, CancellationToken cancellationToken = default) + /// Get test profile run details by test profile run Id. + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual Response GetTestProfileRun(string testProfileRunId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetLatestTestRunInsightsAsync(testRunId, context).ConfigureAwait(false); - return Response.FromValue(TestRunInsights.FromResponse(response), response); + Response result = GetTestProfileRun(testProfileRunId, cancellationToken.ToRequestContext()); + return Response.FromValue((TestProfileRun)result, result); } - /// Get the latest insights for the 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 GetLatestTestRunInsights(string testRunId, CancellationToken cancellationToken = default) + /// Get test profile run details by test profile run Id. + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetTestProfileRunAsync(string testProfileRunId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetLatestTestRunInsights(testRunId, context); - return Response.FromValue(TestRunInsights.FromResponse(response), response); + Response result = await GetTestProfileRunAsync(testProfileRunId, cancellationToken.ToRequestContext()).ConfigureAwait(false); + return Response.FromValue((TestProfileRun)result, result); } /// - /// [Protocol Method] Get the latest insights for the test run. + /// [Protocol Method] Get all test profile 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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// - /// - /// 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. + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. /// Service returned a non-success status code. /// The response returned from the service. - public virtual async Task GetLatestTestRunInsightsAsync(string testRunId, RequestContext context) + 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) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetLatestTestRunInsights"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestProfileRuns"); scope.Start(); try { - using HttpMessage message = CreateGetLatestTestRunInsightsRequest(testRunId, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return new LoadTestRunClientGetTestProfileRunsCollectionResult( + this, + maxpagesize, + minStartDateTime, + maxStartDateTime, + minEndDateTime, + maxEndDateTime, + createdDateStartTime, + createdDateEndTime, + testProfileRunIds, + testProfileIds, + statuses, + context); } catch (Exception e) { @@ -1621,39 +1893,45 @@ public virtual async Task GetLatestTestRunInsightsAsync(string testRun } /// - /// [Protocol Method] Get the latest insights for the test run. + /// [Protocol Method] Get all test profile 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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// - /// - /// 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. + /// 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 options, which can override default behaviors of the client pipeline on a per-call basis. /// Service returned a non-success status code. /// The response returned from the service. - public virtual Response GetLatestTestRunInsights(string testRunId, RequestContext context) + 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) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetLatestTestRunInsights"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestProfileRuns"); scope.Start(); try { - using HttpMessage message = CreateGetLatestTestRunInsightsRequest(testRunId, context); - return _pipeline.ProcessMessage(message, context); + return new LoadTestRunClientGetTestProfileRunsAsyncCollectionResult( + this, + maxpagesize, + minStartDateTime, + maxStartDateTime, + minEndDateTime, + maxEndDateTime, + createdDateStartTime, + createdDateEndTime, + testProfileRunIds, + testProfileIds, + statuses, + context); } catch (Exception e) { @@ -1662,365 +1940,185 @@ public virtual Response GetLatestTestRunInsights(string testRunId, RequestContex } } - /// 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); + /// Get all test profile runs for the given filters. + /// 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 that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual Pageable GetTestProfileRuns(int? maxpagesize = default, DateTimeOffset? minStartDateTime = default, DateTimeOffset? maxStartDateTime = default, DateTimeOffset? minEndDateTime = default, DateTimeOffset? maxEndDateTime = default, DateTimeOffset? createdDateStartTime = default, DateTimeOffset? createdDateEndTime = default, IEnumerable testProfileRunIds = default, IEnumerable testProfileIds = default, IEnumerable statuses = default, CancellationToken cancellationToken = default) + { + return new LoadTestRunClientGetTestProfileRunsCollectionResultOfT( + this, + maxpagesize, + minStartDateTime, + maxStartDateTime, + minEndDateTime, + maxEndDateTime, + createdDateStartTime, + createdDateEndTime, + testProfileRunIds, + testProfileIds, + statuses, + cancellationToken.ToRequestContext()); + } + + /// Get all test profile runs for the given filters. + /// 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 that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual AsyncPageable GetTestProfileRunsAsync(int? maxpagesize = default, DateTimeOffset? minStartDateTime = default, DateTimeOffset? maxStartDateTime = default, DateTimeOffset? minEndDateTime = default, DateTimeOffset? maxEndDateTime = default, DateTimeOffset? createdDateStartTime = default, DateTimeOffset? createdDateEndTime = default, IEnumerable testProfileRunIds = default, IEnumerable testProfileIds = default, IEnumerable statuses = default, CancellationToken cancellationToken = default) + { + return new LoadTestRunClientGetTestProfileRunsAsyncCollectionResultOfT( + this, + maxpagesize, + minStartDateTime, + maxStartDateTime, + minEndDateTime, + maxEndDateTime, + createdDateStartTime, + createdDateEndTime, + testProfileRunIds, + testProfileIds, + statuses, + cancellationToken.ToRequestContext()); } /// - /// [Protocol Method] List the dimension values for the given metric dimension name. + /// [Protocol Method] Stop test profile run for the given test profile 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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// - /// - /// 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. + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request options, 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 GetMetricDimensionValuesAsync(string testRunId, string name, string metricname, string metricNamespace, string timespan, string interval, RequestContext context) + /// The response returned from the service. + public virtual Response StopTestProfileRun(string testProfileRunId, 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)); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.StopTestProfileRun"); + scope.Start(); + try + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); - 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); + using HttpMessage message = CreateStopTestProfileRunRequest(testProfileRunId, context); + return Pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// - /// [Protocol Method] List the dimension values for the given metric dimension name. + /// [Protocol Method] Stop test profile run for the given test profile 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. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// - /// - /// 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. + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request options, 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 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) + /// The response returned from the service. + public virtual async Task StopTestProfileRunAsync(string testProfileRunId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - Argument.AssertNotNull(metricname, nameof(metricname)); - Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); - Argument.AssertNotNull(timespan, nameof(timespan)); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.StopTestProfileRun"); + scope.Start(); + try + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); - 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); + using HttpMessage message = CreateStopTestProfileRunRequest(testProfileRunId, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } - /// 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. - /// Comma-separated list of test IDs. If you are using testIds, do not send a value for testId. - /// 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, IEnumerable testIds = null, CancellationToken cancellationToken = default) + /// Stop test profile run for the given test profile run Id. + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual Response StopTestProfileRun(string testProfileRunId, 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, testIds, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestRunsNextPageRequest(nextLink, orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, createdByTypes, testIds, context); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => LoadTestRun.DeserializeLoadTestRun(e), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestRuns", "value", "nextLink", maxpagesize, context); - } + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); - /// 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. - /// Comma-separated list of test IDs. If you are using testIds, do not send a value for testId. - /// 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, IEnumerable testIds = 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, testIds, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestRunsNextPageRequest(nextLink, orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, createdByTypes, testIds, context); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => LoadTestRun.DeserializeLoadTestRun(e), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestRuns", "value", "nextLink", maxpagesize, context); + Response result = StopTestProfileRun(testProfileRunId, cancellationToken.ToRequestContext()); + return Response.FromValue((TestProfileRun)result, result); } - /// - /// [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. - /// Comma-separated list of test IDs. If you are using testIds, do not send a value for testId. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Stop test profile run for the given test profile run Id. + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token that can be used to cancel the operation. + /// 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 GetTestRunsAsync(string orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, int? maxpagesize, IEnumerable createdByTypes, IEnumerable testIds, RequestContext context) + public virtual async Task> StopTestProfileRunAsync(string testProfileRunId, CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestRunsRequest(orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, createdByTypes, testIds, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestRunsNextPageRequest(nextLink, orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, createdByTypes, testIds, context); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestRuns", "value", "nextLink", maxpagesize, context); - } + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); - /// - /// [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. - /// Comma-separated list of test IDs. If you are using testIds, do not send a value for testId. - /// 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, IEnumerable testIds, RequestContext context) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestRunsRequest(orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, createdByTypes, testIds, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestRunsNextPageRequest(nextLink, orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, createdByTypes, testIds, context); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestRuns", "value", "nextLink", maxpagesize, context); + Response result = await StopTestProfileRunAsync(testProfileRunId, cancellationToken.ToRequestContext()).ConfigureAwait(false); + return Response.FromValue((TestProfileRun)result, result); } - // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method /// - /// [Protocol Method] Generate insights for the test run. + /// [Protocol Method] Get the latest insights for the test run. /// /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// - /// 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 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. + /// The request options, 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 representing an asynchronous operation on the service. - public virtual async Task GenerateTestRunInsightsAsync(WaitUntil waitUntil, string testRunId, RequestContext context = null) + /// The response returned from the service. + public virtual Response GetLatestTestRunInsights(string testRunId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GenerateTestRunInsights"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetLatestTestRunInsights"); scope.Start(); try { - using HttpMessage message = CreateGenerateTestRunInsightsRequest(testRunId, context); - return await ProtocolOperationHelpers.ProcessMessageWithoutResponseValueAsync(_pipeline, message, ClientDiagnostics, "LoadTestRunClient.GenerateTestRunInsights", OperationFinalStateVia.OperationLocation, context, waitUntil).ConfigureAwait(false); + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using HttpMessage message = CreateGetLatestTestRunInsightsRequest(testRunId, context); + return Pipeline.ProcessMessage(message, context); } catch (Exception e) { @@ -2029,37 +2127,33 @@ public virtual async Task GenerateTestRunInsightsAsync(WaitUntil wait } } - // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method /// - /// [Protocol Method] Generate insights for the test run. + /// [Protocol Method] Get the latest insights for the test run. /// /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// - /// 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 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. + /// The request options, 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 representing an asynchronous operation on the service. - public virtual Operation GenerateTestRunInsights(WaitUntil waitUntil, string testRunId, RequestContext context = null) + /// The response returned from the service. + public virtual async Task GetLatestTestRunInsightsAsync(string testRunId, RequestContext context) { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GenerateTestRunInsights"); + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetLatestTestRunInsights"); scope.Start(); try { - using HttpMessage message = CreateGenerateTestRunInsightsRequest(testRunId, context); - return ProtocolOperationHelpers.ProcessMessageWithoutResponseValue(_pipeline, message, ClientDiagnostics, "LoadTestRunClient.GenerateTestRunInsights", OperationFinalStateVia.OperationLocation, context, waitUntil); + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using HttpMessage message = CreateGetLatestTestRunInsightsRequest(testRunId, context); + return await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) { @@ -2068,537 +2162,126 @@ public virtual Operation GenerateTestRunInsights(WaitUntil waitUntil, string tes } } - 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; - 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, 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-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); - } - 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 CreateStopTestRunRequest(string testRunId, RequestContext context) + /// Get the latest insights for the test run. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual Response GetLatestTestRunInsights(string testRunId, CancellationToken cancellationToken = default) { - 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; - } + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - 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; + Response result = GetLatestTestRunInsights(testRunId, cancellationToken.ToRequestContext()); + return Response.FromValue((TestRunInsights)result, result); } - internal HttpMessage CreateDeleteTestProfileRunRequest(string testProfileRunId, RequestContext context) + /// Get the latest insights for the test run. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetLatestTestRunInsightsAsync(string testRunId, CancellationToken cancellationToken = default) { - 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; - return message; - } + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - 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; + Response result = await GetLatestTestRunInsightsAsync(testRunId, cancellationToken.ToRequestContext()).ConfigureAwait(false); + return Response.FromValue((TestRunInsights)result, result); } - 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) + /// Generate insights for the test run. + /// 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 name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The request options, 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. + /// The response returned from the service. + public virtual Operation GenerateTestRunInsights(WaitUntil waitUntil, 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-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) + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GenerateTestRunInsights"); + scope.Start(); + try { - uri.AppendQuery("createdDateEndTime", createdDateEndTime.Value, "O", true); + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using HttpMessage message = CreateGenerateTestRunInsightsRequest(testRunId, context); + return ProtocolOperationHelpers.ProcessMessage(Pipeline, message, ClientDiagnostics, "LoadTestRunClient.GenerateTestRunInsights", OperationFinalStateVia.OperationLocation, context, waitUntil); } - if (testProfileRunIds != null && !(testProfileRunIds is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) + catch (Exception e) { - uri.AppendQueryDelimited("testProfileRunIds", testProfileRunIds, ",", true); + scope.Failed(e); + throw; } - if (testProfileIds != null && !(testProfileIds is ChangeTrackingList changeTrackingList0 && changeTrackingList0.IsUndefined)) + } + + /// Generate insights for the test run. + /// 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 name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The request options, 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. + /// The response returned from the service. + public virtual async Task GenerateTestRunInsightsAsync(WaitUntil waitUntil, string testRunId, RequestContext context) + { + using DiagnosticScope scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GenerateTestRunInsights"); + scope.Start(); + try { - uri.AppendQueryDelimited("testProfileIds", testProfileIds, ",", true); + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using HttpMessage message = CreateGenerateTestRunInsightsRequest(testRunId, context); + return await ProtocolOperationHelpers.ProcessMessageAsync(Pipeline, message, ClientDiagnostics, "LoadTestRunClient.GenerateTestRunInsightsAsync", OperationFinalStateVia.OperationLocation, context, waitUntil).ConfigureAwait(false); } - if (statuses != null && !(statuses is ChangeTrackingList changeTrackingList1 && changeTrackingList1.IsUndefined)) + catch (Exception e) { - uri.AppendQueryDelimited("statuses", statuses, ",", true); + scope.Failed(e); + throw; } - 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 CreateGetLatestTestRunInsightsRequest(string testRunId, RequestContext context) + /// Generate insights for the test run. + /// 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 name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Operation GenerateTestRunInsights(WaitUntil waitUntil, string testRunId, CancellationToken cancellationToken = default) { - 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("/insights/latest", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - internal HttpMessage CreateGenerateTestRunInsightsRequest(string testRunId, 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("/test-runs/", false); - uri.AppendPath(testRunId, true); - uri.AppendPath("/insights:generate", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; + return GenerateTestRunInsights(waitUntil, testRunId, cancellationToken.ToRequestContext()); } - internal HttpMessage CreateGetMetricDimensionValuesNextPageRequest(string nextLink, string testRunId, string name, string metricname, string metricNamespace, string timespan, string interval, RequestContext context) + /// Generate insights for the test run. + /// 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 name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task GenerateTestRunInsightsAsync(WaitUntil waitUntil, string testRunId, CancellationToken cancellationToken = default) { - 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; - } + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - 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; + return await GenerateTestRunInsightsAsync(waitUntil, testRunId, cancellationToken.ToRequestContext()).ConfigureAwait(false); } - - internal HttpMessage CreateGetTestRunsNextPageRequest(string nextLink, string orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, int? maxpagesize, IEnumerable createdByTypes, 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 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 }); - private static ResponseClassifier _responseClassifier202; - private static ResponseClassifier ResponseClassifier202 => _responseClassifier202 ??= new StatusCodeClassifier(stackalloc ushort[] { 202 }); } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingAppComponent.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingAppComponent.Serialization.cs index 80db9363c235..7a0310f9e7e9 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingAppComponent.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingAppComponent.Serialization.cs @@ -13,10 +13,16 @@ namespace Azure.Developer.LoadTesting { - public partial class LoadTestingAppComponent : IUtf8JsonSerializable, IJsonModel + /// 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 : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal LoadTestingAppComponent() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +34,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade /// 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; + string 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); @@ -63,15 +68,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("kind"u8); writer.WriteStringValue(Kind); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -80,22 +85,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - LoadTestingAppComponent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + LoadTestingAppComponent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual LoadTestingAppComponent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static LoadTestingAppComponent DeserializeLoadTestingAppComponent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -107,51 +117,49 @@ internal static LoadTestingAppComponent DeserializeLoadTestingAppComponent(JsonE string resourceGroup = default; string subscriptionId = default; string kind = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("resourceId"u8)) + if (prop.NameEquals("resourceId"u8)) { - resourceId = new ResourceIdentifier(property.Value.GetString()); + resourceId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("resourceName"u8)) + if (prop.NameEquals("resourceName"u8)) { - resourceName = property.Value.GetString(); + resourceName = prop.Value.GetString(); continue; } - if (property.NameEquals("resourceType"u8)) + if (prop.NameEquals("resourceType"u8)) { - resourceType = property.Value.GetString(); + resourceType = prop.Value.GetString(); continue; } - if (property.NameEquals("displayName"u8)) + if (prop.NameEquals("displayName"u8)) { - displayName = property.Value.GetString(); + displayName = prop.Value.GetString(); continue; } - if (property.NameEquals("resourceGroup"u8)) + if (prop.NameEquals("resourceGroup"u8)) { - resourceGroup = property.Value.GetString(); + resourceGroup = prop.Value.GetString(); continue; } - if (property.NameEquals("subscriptionId"u8)) + if (prop.NameEquals("subscriptionId"u8)) { - subscriptionId = property.Value.GetString(); + subscriptionId = prop.Value.GetString(); continue; } - if (property.NameEquals("kind"u8)) + if (prop.NameEquals("kind"u8)) { - kind = property.Value.GetString(); + kind = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new LoadTestingAppComponent( resourceId, resourceName, @@ -160,13 +168,16 @@ internal static LoadTestingAppComponent DeserializeLoadTestingAppComponent(JsonE resourceGroup, subscriptionId, kind, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -176,15 +187,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt } } - LoadTestingAppComponent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + LoadTestingAppComponent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual LoadTestingAppComponent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeLoadTestingAppComponent(document.RootElement, options); } default: @@ -192,22 +208,7 @@ LoadTestingAppComponent IPersistableModel.Create(Binary } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingAppComponent.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingAppComponent.cs index ecd42ad181a8..9d95193ce3d3 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingAppComponent.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingAppComponent.cs @@ -14,37 +14,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// Azure resource name, required while creating the app component. @@ -67,8 +38,8 @@ public LoadTestingAppComponent(string resourceName, string resourceType) /// 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) + /// 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 additionalBinaryDataProperties) { ResourceId = resourceId; ResourceName = resourceName; @@ -77,26 +48,27 @@ internal LoadTestingAppComponent(ResourceIdentifier resourceId, string resourceN ResourceGroup = resourceGroup; SubscriptionId = subscriptionId; Kind = kind; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal LoadTestingAppComponent() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/AzureLoadTestingClientBuilderExtensions.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingClientBuilderExtensions.cs similarity index 53% rename from sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/AzureLoadTestingClientBuilderExtensions.cs rename to sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingClientBuilderExtensions.cs index 4fd2697f2890..51bae5f14d3c 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/AzureLoadTestingClientBuilderExtensions.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingClientBuilderExtensions.cs @@ -12,44 +12,53 @@ namespace Microsoft.Extensions.Azure { - /// Extension methods to add , to client builder. - public static partial class AzureLoadTestingClientBuilderExtensions + /// Extension methods to add clients to . + public static partial class LoadTestingClientBuilderExtensions { - /// Registers a instance. + /// Registers a client with the specified . /// The builder to register with. - /// The to use. - public static IAzureClientBuilder AddLoadTestAdministrationClient(this TBuilder builder, Uri endpoint) - where TBuilder : IAzureClientFactoryBuilderWithCredential + /// + /// is null. + /// is an empty string, and was expected to be non-empty. + public static IAzureClientBuilder AddLoadTestAdministrationClient(this TBuilder builder, string endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential { - return builder.RegisterClientFactory((options, cred) => new LoadTestAdministrationClient(endpoint, cred, options)); - } + Argument.AssertNotNullOrEmpty(endpoint, nameof(endpoint)); - /// 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)); + return builder.RegisterClientFactory((options, credential) => new LoadTestAdministrationClient(endpoint, credential, options)); } - /// Registers a instance. + /// Registers a client with the specified . /// The builder to register with. - /// The configuration values. + /// The configuration to use for the client. [RequiresUnreferencedCode("Requires unreferenced code until we opt into EnableConfigurationBindingGenerator.")] [RequiresDynamicCode("Requires unreferenced code until we opt into EnableConfigurationBindingGenerator.")] public static IAzureClientBuilder AddLoadTestAdministrationClient(this TBuilder builder, TConfiguration configuration) - where TBuilder : IAzureClientFactoryBuilderWithConfiguration + where TBuilder : IAzureClientFactoryBuilderWithConfiguration { return builder.RegisterClientFactory(configuration); } - /// Registers a instance. + + /// Registers a client with the specified . + /// The builder to register with. + /// + /// is null. + /// is an empty string, and was expected to be non-empty. + public static IAzureClientBuilder AddLoadTestRunClient(this TBuilder builder, string endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential + { + Argument.AssertNotNullOrEmpty(endpoint, nameof(endpoint)); + + return builder.RegisterClientFactory((options, credential) => new LoadTestRunClient(endpoint, credential, options)); + } + + /// Registers a client with the specified . /// The builder to register with. - /// The configuration values. + /// The configuration to use for the client. [RequiresUnreferencedCode("Requires unreferenced code until we opt into EnableConfigurationBindingGenerator.")] [RequiresDynamicCode("Requires unreferenced code until we opt into EnableConfigurationBindingGenerator.")] public static IAzureClientBuilder AddLoadTestRunClient(this TBuilder builder, TConfiguration configuration) - where TBuilder : IAzureClientFactoryBuilderWithConfiguration + where TBuilder : IAzureClientFactoryBuilderWithConfiguration { return builder.RegisterClientFactory(configuration); } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingClientOptions.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingClientOptions.cs index 809660a70f6d..75cfd98a1840 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingClientOptions.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingClientOptions.cs @@ -10,33 +10,13 @@ namespace Azure.Developer.LoadTesting { - /// Client options for Azure.Developer.LoadTesting library clients. + /// Client options for clients in this library. public partial class LoadTestingClientOptions : 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 LoadTestingClientOptions. + /// Initializes a new instance of LoadTestAdministrationClientOptions. + /// The service version. public LoadTestingClientOptions(ServiceVersion version = LatestVersion) { Version = version switch @@ -51,5 +31,27 @@ public LoadTestingClientOptions(ServiceVersion version = LatestVersion) _ => throw new NotSupportedException() }; } + + /// Gets the Version. + internal string Version { get; } + + /// The version of the service to use. + public enum ServiceVersion + { + /// The 2022-11-01 version of the Azure Load Testing API. + V2022_11_01 = 1, + /// The 2023-04-01-preview version of the Azure Load Testing API. + V2023_04_01_Preview = 2, + /// The 2024-03-01-preview version of the Azure Load Testing API. + V2024_03_01_Preview = 3, + /// The 2024-05-01-preview version of the Azure Load Testing API. + V2024_05_01_Preview = 4, + /// The 2024-07-01-preview version of the Azure Load Testing API. + V2024_07_01_Preview = 5, + /// The 2024-12-01-preview version of the Azure Load Testing API. + V2024_12_01_Preview = 6, + /// The 2025-03-01-preview version of the Azure Load Testing API. + V2025_03_01_Preview = 7 + } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingFileType.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingFileType.cs index 78387b0fae18..061eb6a1192e 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingFileType.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingFileType.cs @@ -14,50 +14,77 @@ namespace Azure.Developer.LoadTesting 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)); - } - + /// If the file is a JMX script. private const string JmxFileValue = "JMX_FILE"; + /// If the file is a user properties file. private const string UserPropertiesValue = "USER_PROPERTIES"; + /// If the file is not among any of the other supported file types. private const string AdditionalArtifactsValue = "ADDITIONAL_ARTIFACTS"; + /// If the file is a compressed archive containing a collection of various artifacts or resources. private const string ZippedArtifactsValue = "ZIPPED_ARTIFACTS"; + /// If the file is a JSON config file to define the requests for a URL test. private const string UrlTestConfigValue = "URL_TEST_CONFIG"; + /// If the file is a test script. private const string TestScriptValue = "TEST_SCRIPT"; + /// Initializes a new instance of . + /// The value. + /// is null. + public LoadTestingFileType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(LoadTestingFileType left, LoadTestingFileType right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(LoadTestingFileType left, LoadTestingFileType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator LoadTestingFileType(string value) => new LoadTestingFileType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator LoadTestingFileType?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingManagedIdentityType.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingManagedIdentityType.cs index 3919a0d3c86d..d11ea6875bc8 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingManagedIdentityType.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingManagedIdentityType.cs @@ -14,38 +14,57 @@ namespace Azure.Developer.LoadTesting public readonly partial struct LoadTestingManagedIdentityType : IEquatable { private readonly string _value; + /// System-assigned managed identity. + private const string SystemAssignedValue = "SystemAssigned"; + /// User-assigned managed identity. + private const string UserAssignedValue = "UserAssigned"; /// Initializes a new instance of . + /// The value. /// is null. public LoadTestingManagedIdentityType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string SystemAssignedValue = "SystemAssigned"; - private const string UserAssignedValue = "UserAssigned"; + _value = value; + } /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(LoadTestingManagedIdentityType left, LoadTestingManagedIdentityType right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(LoadTestingManagedIdentityType left, LoadTestingManagedIdentityType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator LoadTestingManagedIdentityType(string value) => new LoadTestingManagedIdentityType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator LoadTestingManagedIdentityType?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingModelFactory.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingModelFactory.cs index d776f0a10ade..9379eadca3d9 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingModelFactory.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingModelFactory.cs @@ -8,14 +8,15 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure; using Azure.Core; namespace Azure.Developer.LoadTesting { - /// Model factory for models. + /// A factory class for creating instances of the models for mocking. public static partial class LoadTestingModelFactory { - /// Initializes a new instance of . + /// Load test model. /// 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. /// @@ -48,11 +49,11 @@ public static partial class LoadTestingModelFactory /// 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, double? estimatedVirtualUserHours = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + public static LoadTest LoadTest(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, IEnumerable engineBuiltInIdentityIds = default, double? estimatedVirtualUserHours = default, DateTimeOffset? createdDateTime = default, string createdBy = default, DateTimeOffset? lastModifiedDateTime = default, string lastModifiedBy = default) { - secrets ??= new Dictionary(); - environmentVariables ??= new Dictionary(); - engineBuiltInIdentityIds ??= new List(); + secrets ??= new ChangeTrackingDictionary(); + environmentVariables ??= new ChangeTrackingDictionary(); + engineBuiltInIdentityIds ??= new ChangeTrackingList(); return new LoadTest( passFailCriteria, @@ -74,16 +75,28 @@ public static LoadTest LoadTest(PassFailCriteria passFailCriteria = null, AutoSt metricsReferenceIdentityType, metricsReferenceIdentityId, engineBuiltInIdentityType, - engineBuiltInIdentityIds?.ToList(), + engineBuiltInIdentityIds.ToList(), estimatedVirtualUserHours, createdDateTime, createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Pass fail criteria for a test. + /// Map of id and pass fail metrics { id : pass fail metrics }. + /// Map of id and pass fail server metrics { id : pass fail metrics }. + /// A new instance for mocking. + public static PassFailCriteria PassFailCriteria(IDictionary passFailMetrics = default, IDictionary passFailServerMetrics = default) + { + passFailMetrics ??= new ChangeTrackingDictionary(); + passFailServerMetrics ??= new ChangeTrackingDictionary(); + + return new PassFailCriteria(passFailMetrics, passFailServerMetrics, additionalBinaryDataProperties: null); + } + + /// Pass fail metric. /// The client metric on which the criteria should be applied. /// /// The aggregation function to be applied on the client metric. Allowed functions @@ -91,8 +104,8 @@ public static LoadTest LoadTest(PassFailCriteria passFailCriteria = null, AutoSt /// ‘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 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. @@ -101,7 +114,7 @@ public static LoadTest LoadTest(PassFailCriteria passFailCriteria = null, AutoSt /// 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) + public static PassFailMetric PassFailMetric(PfMetrics? clientMetric = default, PassFailAggregationFunction? aggregate = default, string condition = default, string requestName = default, double? value = default, PassFailAction? action = default, double? actualValue = default, PassFailResult? result = default) { return new PassFailMetric( clientMetric, @@ -112,21 +125,21 @@ public static PassFailMetric PassFailMetric(PfMetrics? clientMetric = null, Pass action, actualValue, result, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Pass fail server metric. /// 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 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. + /// 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) + public static PassFailServerMetric PassFailServerMetric(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) { return new PassFailServerMetric( resourceId, @@ -138,10 +151,101 @@ public static PassFailServerMetric PassFailServerMetric(ResourceIdentifier resou action, actualValue, result, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); + } + + /// Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. + /// 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. + /// A new instance for mocking. + public static AutoStopCriteria AutoStopCriteria(bool? autoStopDisabled = default, float? errorRate = default, TimeSpan? errorRateTimeWindow = default, int? maximumVirtualUsersPerEngine = default) + { + return new AutoStopCriteria(autoStopDisabled, errorRate, errorRateTimeWindow, maximumVirtualUsersPerEngine, additionalBinaryDataProperties: null); + } + + /// Secret. + /// The value of the secret for the respective type. + /// Type of secret. + /// A new instance for mocking. + public static TestSecret TestSecret(string value = default, SecretType? secretKind = default) + { + return new TestSecret(value, secretKind, additionalBinaryDataProperties: null); + } + + /// Certificates metadata. + /// The value of the certificate for respective type. + /// Type of certificate. + /// Name of the certificate. + /// A new instance for mocking. + public static TestCertificate TestCertificate(string value = default, CertificateType? certificateKind = default, string name = default) + { + return new TestCertificate(value, certificateKind, name, additionalBinaryDataProperties: null); + } + + /// Configurations for the load test. + /// 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. + /// A new instance for mocking. + public static LoadTestConfiguration LoadTestConfiguration(int? engineInstances = default, bool? splitAllCsvs = default, bool? quickStartTest = default, OptionalLoadTestConfiguration optionalLoadTestConfiguration = default, IEnumerable regionalLoadTestConfiguration = default) + { + regionalLoadTestConfiguration ??= new ChangeTrackingList(); + + return new LoadTestConfiguration( + engineInstances, + splitAllCsvs, + quickStartTest, + optionalLoadTestConfiguration, + regionalLoadTestConfiguration.ToList(), + additionalBinaryDataProperties: null); + } + + /// Configuration for quick load test. + /// 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. + /// A new instance for mocking. + public static OptionalLoadTestConfiguration OptionalLoadTestConfiguration(Uri endpointUri = default, int? requestsPerSecond = default, int? maxResponseTimeInMs = default, int? virtualUsers = default, int? rampUpTime = default, TimeSpan? duration = default) + { + return new OptionalLoadTestConfiguration( + endpointUri, + requestsPerSecond, + maxResponseTimeInMs, + virtualUsers, + rampUpTime, + duration, + additionalBinaryDataProperties: null); + } + + /// Region distribution configuration for the load test. + /// 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. + /// + /// A new instance for mocking. + public static RegionalConfiguration RegionalConfiguration(int engineInstances = default, AzureLocation region = default) + { + return new RegionalConfiguration(engineInstances, region, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// The input artifacts for the test. /// The load test YAML file that contains the the test configuration. /// The test script file for the test run. /// The user properties file. @@ -149,9 +253,9 @@ public static PassFailServerMetric PassFailServerMetric(ResourceIdentifier resou /// 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) + public static TestInputArtifacts TestInputArtifacts(TestFileInfo configFileInfo = default, TestFileInfo testScriptFileInfo = default, TestFileInfo userPropertyFileInfo = default, TestFileInfo inputArtifactsZipFileInfo = default, TestFileInfo urlTestConfigFileInfo = default, IEnumerable additionalFileInfo = default) { - additionalFileInfo ??= new List(); + additionalFileInfo ??= new ChangeTrackingList(); return new TestInputArtifacts( configFileInfo, @@ -159,11 +263,11 @@ public static TestInputArtifacts TestInputArtifacts(TestFileInfo configFileInfo userPropertyFileInfo, inputArtifactsZipFileInfo, urlTestConfigFileInfo, - additionalFileInfo?.ToList(), - serializedAdditionalRawData: null); + additionalFileInfo.ToList(), + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Test file info. /// Name of the file. /// File URL. /// File type. @@ -171,7 +275,7 @@ public static TestInputArtifacts TestInputArtifacts(TestFileInfo configFileInfo /// 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) + public static TestFileInfo TestFileInfo(string fileName = default, Uri uri = default, LoadTestingFileType? fileType = default, DateTimeOffset? expiresOn = default, FileValidationStatus? validationStatus = default, string validationFailureDetails = default) { return new TestFileInfo( fileName, @@ -180,14 +284,14 @@ public static TestFileInfo TestFileInfo(string fileName = null, Uri uri = null, expiresOn, validationStatus, validationFailureDetails, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Test app components. /// /// Azure resource collection { resource id (fully qualified resource Id e.g /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) - /// : resource object } + /// : resource object } /// /// Test identifier. /// The creation datetime(RFC 3339 literal format). @@ -195,9 +299,9 @@ public static TestFileInfo TestFileInfo(string fileName = null, Uri uri = null, /// 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) + public static TestAppComponents TestAppComponents(IDictionary components = default, string testId = default, DateTimeOffset? createdDateTime = default, string createdBy = default, DateTimeOffset? lastModifiedDateTime = default, string lastModifiedBy = default) { - components ??= new Dictionary(); + components ??= new ChangeTrackingDictionary(); return new TestAppComponents( components, @@ -206,10 +310,10 @@ public static TestAppComponents TestAppComponents(IDictionary Initializes a new instance of . + /// An Azure resource object (Refer azure generic resource model :https://learn.microsoft.com/en-us/rest/api/resources/resources/get-by-id#genericresource). /// 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. @@ -218,7 +322,7 @@ public static TestAppComponents TestAppComponents(IDictionary 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) + public static LoadTestingAppComponent LoadTestingAppComponent(ResourceIdentifier resourceId = default, string resourceName = default, string resourceType = default, string displayName = default, string resourceGroup = default, string subscriptionId = default, string kind = default) { return new LoadTestingAppComponent( resourceId, @@ -228,10 +332,10 @@ public static LoadTestingAppComponent LoadTestingAppComponent(ResourceIdentifier resourceGroup, subscriptionId, kind, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Test server metrics configuration. /// Test identifier. /// /// Azure resource metrics collection {metric id : metrics object} (Refer : @@ -243,9 +347,9 @@ public static LoadTestingAppComponent LoadTestingAppComponent(ResourceIdentifier /// 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) + public static TestServerMetricsConfiguration TestServerMetricsConfiguration(string testId = default, IDictionary metrics = default, DateTimeOffset? createdDateTime = default, string createdBy = default, DateTimeOffset? lastModifiedDateTime = default, string lastModifiedBy = default) { - metrics ??= new Dictionary(); + metrics ??= new ChangeTrackingDictionary(); return new TestServerMetricsConfiguration( testId, @@ -254,10 +358,14 @@ public static TestServerMetricsConfiguration TestServerMetricsConfiguration(stri createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// + /// Associated metric definition for particular metrics of the azure resource ( + /// Refer : + /// https://learn.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). + /// /// Unique name for metric. /// Azure resource id. /// Metric name space. @@ -267,7 +375,7 @@ public static TestServerMetricsConfiguration TestServerMetricsConfiguration(stri /// 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) + public static ResourceMetric ResourceMetric(string id = default, ResourceIdentifier resourceId = default, string metricNamespace = default, string displayDescription = default, string name = default, string aggregation = default, string unit = default, string resourceType = default) { return new ResourceMetric( id, @@ -278,26 +386,22 @@ public static ResourceMetric ResourceMetric(string id = null, ResourceIdentifier aggregation, unit, resourceType, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Test Profile Model. /// 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 . - /// + /// Configurations of the target resource on which testing would be done. /// 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) + public static TestProfile TestProfile(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) { return new TestProfile( testProfileId, @@ -310,10 +414,43 @@ public static TestProfile TestProfile(string testProfileId = null, string displa createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); + } + + /// + /// Configurations of a target resource. This varies with the kind of resource. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// + /// Kind of the resource for which the configurations apply. + /// A new instance for mocking. + public static TargetResourceConfigurations TargetResourceConfigurations(string kind = default) + { + return new UnknownTargetResourceConfigurations(new ResourceKind(kind), additionalBinaryDataProperties: null); + } + + /// Configurations for a Function App using Flex Consumption Plan. + /// A map of configurations for a Function app using Flex Consumption Plan. + /// A new instance for mocking. + public static FunctionFlexConsumptionTargetResourceConfigurations FunctionFlexConsumptionTargetResourceConfigurations(IDictionary configurations = default) + { + configurations ??= new ChangeTrackingDictionary(); + + return new FunctionFlexConsumptionTargetResourceConfigurations(ResourceKind.FunctionsFlexConsumption, additionalBinaryDataProperties: null, configurations); + } + + /// Resource configuration instance for a Flex Consumption based Azure Function App. + /// Memory size of the instance. Supported values are 2048, 4096. + /// HTTP Concurrency for the function app. + /// A new instance for mocking. + public static FunctionFlexConsumptionResourceConfiguration FunctionFlexConsumptionResourceConfiguration(long instanceMemoryMB = default, long? httpConcurrency = default) + { + return new FunctionFlexConsumptionResourceConfiguration(instanceMemoryMB, httpConcurrency, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// + /// Trigger model. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// /// The unique identifier of the trigger. /// The name of the trigger. /// The description of the trigger. @@ -325,31 +462,31 @@ public static TestProfile TestProfile(string testProfileId = null, string displa /// The last Modified datetime(RFC 3339 literal format). /// The user that last modified. /// A new instance for mocking. - public static LoadTestingTrigger LoadTestingTrigger(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) + public static LoadTestingTrigger LoadTestingTrigger(string triggerId = default, string displayName = default, string description = default, string kind = default, TriggerState? state = default, StateDetails stateDetails = default, DateTimeOffset? createdDateTime = default, string createdBy = default, DateTimeOffset? lastModifiedDateTime = default, string lastModifiedBy = default) { return new UnknownLoadTestingTrigger( triggerId, displayName, description, - kind == null ? default : new TriggerType(kind), + new TriggerType(kind), state, stateDetails, createdDateTime, createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// State details of the trigger. /// The error message if the trigger is in disabled state. /// A new instance for mocking. - public static StateDetails StateDetails(string message = null) + public static StateDetails StateDetails(string message = default) { - return new StateDetails(message, serializedAdditionalRawData: null); + return new StateDetails(message, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// ScheduleTestsTrigger model. /// The unique identifier of the trigger. /// The name of the trigger. /// The description of the trigger. @@ -362,15 +499,11 @@ public static StateDetails StateDetails(string message = null) /// 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 . - /// + /// Recurrence details of the trigger. Null if schedule is not recurring. /// 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, LoadTestingRecurrence recurrence = null) + public static ScheduleTestsTrigger ScheduleTestsTrigger(string triggerId = default, string displayName = default, string description = default, TriggerState? state = default, StateDetails stateDetails = default, DateTimeOffset? createdDateTime = default, string createdBy = default, DateTimeOffset? lastModifiedDateTime = default, string lastModifiedBy = default, IEnumerable testIds = default, DateTimeOffset? startDateTime = default, RecurrenceStatus recurrenceStatus = default, LoadTestingRecurrence recurrence = default) { - testIds ??= new List(); + testIds ??= new ChangeTrackingList(); return new ScheduleTestsTrigger( triggerId, @@ -383,25 +516,119 @@ public static ScheduleTestsTrigger ScheduleTestsTrigger(string triggerId = null, createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData: null, - testIds?.ToList(), + additionalBinaryDataProperties: null, + testIds.ToList(), startDateTime, recurrenceStatus, recurrence); } - /// Initializes a new instance of . + /// Actual state of the recurrence for the trigger. /// 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) + public static RecurrenceStatus RecurrenceStatus(int? remainingOccurrences = default, IEnumerable nextScheduledDateTimes = default) + { + nextScheduledDateTimes ??= new ChangeTrackingList(); + + return new RecurrenceStatus(remainingOccurrences, nextScheduledDateTimes.ToList(), additionalBinaryDataProperties: null); + } + + /// + /// Recurrence model. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , , and . + /// + /// 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. + /// A new instance for mocking. + public static LoadTestingRecurrence LoadTestingRecurrence(string frequency = default, RecurrenceEnd recurrenceEnd = default) + { + return new UnknownLoadTestingRecurrence(new Frequency(frequency), recurrenceEnd, additionalBinaryDataProperties: null); + } + + /// 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. + /// Number of occurrences after which the recurrence will end. + /// The date after which the recurrence will end. (RFC 3339 literal format). + /// A new instance for mocking. + public static RecurrenceEnd RecurrenceEnd(int? numberOfOccurrences = default, DateTimeOffset? endDateTime = default) { - nextScheduledDateTimes ??= new List(); + return new RecurrenceEnd(numberOfOccurrences, endDateTime, additionalBinaryDataProperties: null); + } + + /// Recurrence model when frequency is set as Daily. + /// 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. + /// The interval at which the recurrence should repeat. It signifies the number of days between each recurrence. + /// A new instance for mocking. + public static DailyRecurrence DailyRecurrence(RecurrenceEnd recurrenceEnd = default, int interval = default) + { + return new DailyRecurrence(Frequency.Daily, recurrenceEnd, additionalBinaryDataProperties: null, interval); + } + + /// Recurrence model when frequency is set as Hourly. + /// 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. + /// The interval at which the recurrence should repeat. It signifies the number of hours between each recurrence. + /// A new instance for mocking. + public static HourlyRecurrence HourlyRecurrence(RecurrenceEnd recurrenceEnd = default, int interval = default) + { + return new HourlyRecurrence(Frequency.Hourly, recurrenceEnd, additionalBinaryDataProperties: null, interval); + } + + /// Recurrence model when frequency is set as MonthlyByDays . + /// 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. + /// 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. + /// A new instance for mocking. + public static MonthlyRecurrenceByWeekDays MonthlyRecurrenceByWeekDays(RecurrenceEnd recurrenceEnd = default, IEnumerable weekDaysInMonth = default, int index = default, int interval = default) + { + weekDaysInMonth ??= new ChangeTrackingList(); + + return new MonthlyRecurrenceByWeekDays( + Frequency.MonthlyByDays, + recurrenceEnd, + additionalBinaryDataProperties: null, + weekDaysInMonth.ToList(), + index, + interval); + } + + /// Recurrence model when frequency is set as MonthlyByDates. + /// 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. + /// 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. + /// A new instance for mocking. + public static MonthlyRecurrenceByDates MonthlyRecurrenceByDates(RecurrenceEnd recurrenceEnd = default, IEnumerable datesInMonth = default, int? interval = default) + { + datesInMonth ??= new ChangeTrackingList(); - return new RecurrenceStatus(remainingOccurrences, nextScheduledDateTimes?.ToList(), serializedAdditionalRawData: null); + return new MonthlyRecurrenceByDates(Frequency.MonthlyByDates, recurrenceEnd, additionalBinaryDataProperties: null, datesInMonth.ToList(), interval); } - /// Initializes a new instance of . + /// Recurrence is set based on cron expression. + /// 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. + /// Cron expression for the recurrence. + /// A new instance for mocking. + public static RecurrenceWithCron RecurrenceWithCron(RecurrenceEnd recurrenceEnd = default, string cronExpression = default) + { + return new RecurrenceWithCron(Frequency.Cron, recurrenceEnd, additionalBinaryDataProperties: null, cronExpression); + } + + /// Recurrence model when frequency is set as weekly. + /// 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. + /// 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. + /// A new instance for mocking. + public static WeeklyRecurrence WeeklyRecurrence(RecurrenceEnd recurrenceEnd = default, IEnumerable daysOfWeek = default, int? interval = default) + { + daysOfWeek ??= new ChangeTrackingList(); + + return new WeeklyRecurrence(Frequency.Weekly, recurrenceEnd, additionalBinaryDataProperties: null, daysOfWeek.ToList(), interval); + } + + /// + /// Notification rule model. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// /// The unique identifier of the notification rule. /// The name of the notification rule. /// The action groups to notify. @@ -411,23 +638,23 @@ public static RecurrenceStatus RecurrenceStatus(int? remainingOccurrences = null /// 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) + public static NotificationRule NotificationRule(string notificationRuleId = default, string displayName = default, IEnumerable actionGroupIds = default, string scope = default, DateTimeOffset? createdDateTime = default, string createdBy = default, DateTimeOffset? lastModifiedDateTime = default, string lastModifiedBy = default) { - actionGroupIds ??= new List(); + actionGroupIds ??= new ChangeTrackingList(); return new UnknownNotificationRule( notificationRuleId, displayName, - actionGroupIds?.ToList(), - scope == null ? default : new NotificationScopeType(scope), + actionGroupIds.ToList(), + new NotificationScopeType(scope), createdDateTime, createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Tests Notification rule model. /// The unique identifier of the notification rule. /// The name of the notification rule. /// The action groups to notify. @@ -439,42 +666,92 @@ public static NotificationRule NotificationRule(string notificationRuleId = null /// /// 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) + public static TestsNotificationRule TestsNotificationRule(string notificationRuleId = default, string displayName = default, IEnumerable actionGroupIds = default, DateTimeOffset? createdDateTime = default, string createdBy = default, DateTimeOffset? lastModifiedDateTime = default, string lastModifiedBy = default, IEnumerable testIds = default, IDictionary eventFilters = default) { - actionGroupIds ??= new List(); - testIds ??= new List(); - eventFilters ??= new Dictionary(); + actionGroupIds ??= new ChangeTrackingList(); + testIds ??= new ChangeTrackingList(); + eventFilters ??= new ChangeTrackingDictionary(); return new TestsNotificationRule( notificationRuleId, displayName, - actionGroupIds?.ToList(), + actionGroupIds.ToList(), NotificationScopeType.Tests, createdDateTime, createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData: null, - testIds?.ToList(), + additionalBinaryDataProperties: null, + testIds.ToList(), eventFilters); } - /// Initializes a new instance of . + /// + /// The notification event filter for Tests scope. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , and . + /// + /// The event type. + /// A new instance for mocking. + public static TestsNotificationEventFilter TestsNotificationEventFilter(string kind = default) + { + return new UnknownTestsNotificationEventFilter(new NotificationEventType(kind), additionalBinaryDataProperties: null); + } + + /// The notification event filter when the event type is TestRunEnded and scope is Tests. + /// Event filtering condition. + /// A new instance for mocking. + public static TestRunEndedNotificationEventFilter TestRunEndedNotificationEventFilter(TestRunEndedEventCondition condition = default) + { + return new TestRunEndedNotificationEventFilter(NotificationEventType.TestRunEnded, additionalBinaryDataProperties: null, condition); + } + + /// TestRunEnded Event condition. + /// The test run statuses to send notification for. + /// The test run results to send notification for. + /// A new instance for mocking. + public static TestRunEndedEventCondition TestRunEndedEventCondition(IEnumerable testRunStatuses = default, IEnumerable testRunResults = default) + { + testRunStatuses ??= new ChangeTrackingList(); + testRunResults ??= new ChangeTrackingList(); + + return new TestRunEndedEventCondition(testRunStatuses.ToList(), testRunResults.ToList(), additionalBinaryDataProperties: null); + } + + /// The notification event filter when the event type is TestRunStarted and scope is Tests. + /// A new instance for mocking. + public static TestRunStartedNotificationEventFilter TestRunStartedNotificationEventFilter() + { + return new TestRunStartedNotificationEventFilter(NotificationEventType.TestRunStarted, additionalBinaryDataProperties: null); + } + + /// The notification event filter when the event type is TriggerCompleted. + /// A new instance for mocking. + public static TriggerCompletedNotificationEventFilter TriggerCompletedNotificationEventFilter() + { + return new TriggerCompletedNotificationEventFilter(NotificationEventType.TriggerCompleted, additionalBinaryDataProperties: null); + } + + /// The notification event filter when the event type is TriggerDisabled. + /// A new instance for mocking. + public static TriggerDisabledNotificationEventFilter TriggerDisabledNotificationEventFilter() + { + return new TriggerDisabledNotificationEventFilter(NotificationEventType.TriggerDisabled, additionalBinaryDataProperties: null); + } + + /// Status of a long running operation. /// The unique ID of the operation. /// The state of the operation. /// The kind of the operation. /// Error object that describes the error when status is "Failed". /// A new instance for mocking. - public static OperationStatus OperationStatus(string id = null, OperationState status = default, OperationKind kind = default, ResponseError error = null) + public static OperationStatus OperationStatus(string id = default, OperationState status = default, OperationKind kind = default, ResponseError error = default) { - return new OperationStatus(id, status, kind, error, serializedAdditionalRawData: null); + return new OperationStatus(id, status, kind, error, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Load test run model. /// 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. @@ -525,13 +802,13 @@ public static OperationStatus OperationStatus(string id = null, OperationState s /// 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, double? estimatedVirtualUserHours = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + public static LoadTestRun LoadTestRun(string testRunId = default, PassFailCriteria passFailCriteria = default, AutoStopCriteria autoStopCriteria = default, IDictionary secrets = default, TestCertificate certificate = default, IDictionary environmentVariables = default, IEnumerable 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 portalUri = 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, double? estimatedVirtualUserHours = default, DateTimeOffset? createdDateTime = default, string createdBy = default, DateTimeOffset? lastModifiedDateTime = default, string lastModifiedBy = default) { - secrets ??= new Dictionary(); - environmentVariables ??= new Dictionary(); - errorDetails ??= new List(); - testRunStatistics ??= new Dictionary(); - regionalStatistics ??= new Dictionary(); + secrets ??= new ChangeTrackingDictionary(); + environmentVariables ??= new ChangeTrackingDictionary(); + errorDetails ??= new ChangeTrackingList(); + testRunStatistics ??= new ChangeTrackingDictionary(); + regionalStatistics ??= new ChangeTrackingDictionary(); return new LoadTestRun( testRunId, @@ -540,7 +817,7 @@ public static LoadTestRun LoadTestRun(string testRunId = null, PassFailCriteria secrets, certificate, environmentVariables, - errorDetails?.ToList(), + errorDetails.ToList(), testRunStatistics, regionalStatistics, loadTestConfiguration, @@ -569,22 +846,22 @@ public static LoadTestRun LoadTestRun(string testRunId = null, PassFailCriteria createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Error details if there is any failure in load test run. /// Error code if there is any failure in load test run. /// Error details in case test run was not successfully run. /// A dictionary for storing additional error information for better context. Each key is a property name (e.g., "Description", "Resolution", "Category", "Region"), and its value is an array of strings with relevant details. /// A new instance for mocking. - public static ErrorDetails ErrorDetails(string code = null, string message = null, IReadOnlyDictionary> properties = null) + public static ErrorDetails ErrorDetails(string code = default, string message = default, IReadOnlyDictionary> properties = default) { - properties ??= new Dictionary>(); + properties ??= new ChangeTrackingDictionary>(); - return new ErrorDetails(code, message, properties, serializedAdditionalRawData: null); + return new ErrorDetails(code, message, properties, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Test run statistics. /// Transaction name. /// Sampler count. /// Error count. @@ -606,7 +883,7 @@ public static ErrorDetails ErrorDetails(string code = null, string message = nul /// 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) + public static TestRunStatistics TestRunStatistics(string transaction = default, double? sampleCount = default, double? errorCount = default, double? errorPercentage = default, double? meanResponseTime = default, double? medianResponseTime = default, double? maxResponseTime = default, double? minResponseTime = default, double? percentile90ResponseTime = default, double? percentile95ResponseTime = default, double? percentile99ResponseTime = default, double? percentile75ResponseTime = default, double? percentile96ResponseTime = default, double? percentile97ResponseTime = default, double? percentile98ResponseTime = default, double? percentile999ResponseTime = default, double? percentile9999ResponseTime = default, double? throughput = default, double? receivedKBytesPerSec = default, double? sentKBytesPerSec = default) { return new TestRunStatistics( transaction, @@ -629,19 +906,19 @@ public static TestRunStatistics TestRunStatistics(string transaction = null, dou throughput, receivedKBytesPerSec, sentKBytesPerSec, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Collection of test run artifacts. /// 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) + public static TestRunArtifacts TestRunArtifacts(TestRunInputArtifacts inputArtifacts = default, TestRunOutputArtifacts outputArtifacts = default) { - return new TestRunArtifacts(inputArtifacts, outputArtifacts, serializedAdditionalRawData: null); + return new TestRunArtifacts(inputArtifacts, outputArtifacts, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// The input artifacts for the test run. /// The load test YAML file that contains the the test configuration. /// The test script file for the test run. /// The user properties file. @@ -649,9 +926,9 @@ public static TestRunArtifacts TestRunArtifacts(TestRunInputArtifacts inputArtif /// 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) + public static TestRunInputArtifacts TestRunInputArtifacts(TestRunFileInfo configFileInfo = default, TestRunFileInfo testScriptFileInfo = default, TestRunFileInfo userPropertyFileInfo = default, TestRunFileInfo inputArtifactsZipFileInfo = default, TestRunFileInfo urlTestConfigFileInfo = default, IEnumerable additionalFileInfo = default) { - additionalFileInfo ??= new List(); + additionalFileInfo ??= new ChangeTrackingList(); return new TestRunInputArtifacts( configFileInfo, @@ -659,11 +936,11 @@ public static TestRunInputArtifacts TestRunInputArtifacts(TestRunFileInfo config userPropertyFileInfo, inputArtifactsZipFileInfo, urlTestConfigFileInfo, - additionalFileInfo?.ToList(), - serializedAdditionalRawData: null); + additionalFileInfo.ToList(), + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Test run file info. /// Name of the file. /// File URL. /// File type. @@ -671,7 +948,7 @@ public static TestRunInputArtifacts TestRunInputArtifacts(TestRunFileInfo config /// 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) + public static TestRunFileInfo TestRunFileInfo(string fileName = default, Uri uri = default, LoadTestingFileType? fileType = default, DateTimeOffset? expiresOn = default, FileValidationStatus? validationStatus = default, string validationFailureDetails = default) { return new TestRunFileInfo( fileName, @@ -680,34 +957,34 @@ public static TestRunFileInfo TestRunFileInfo(string fileName = null, Uri uri = expiresOn, validationStatus, validationFailureDetails, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// The output artifacts for the test run. /// 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) + public static TestRunOutputArtifacts TestRunOutputArtifacts(TestRunFileInfo resultFileInfo = default, TestRunFileInfo logsFileInfo = default, ArtifactsContainerInfo artifactsContainerInfo = default, TestRunFileInfo reportFileInfo = default) { - return new TestRunOutputArtifacts(resultFileInfo, logsFileInfo, artifactsContainerInfo, reportFileInfo, serializedAdditionalRawData: null); + return new TestRunOutputArtifacts(resultFileInfo, logsFileInfo, artifactsContainerInfo, reportFileInfo, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Artifacts container info. /// 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) + public static ArtifactsContainerInfo ArtifactsContainerInfo(Uri uri = default, DateTimeOffset? expiresOn = default) { - return new ArtifactsContainerInfo(uri, expiresOn, serializedAdditionalRawData: null); + return new ArtifactsContainerInfo(uri, expiresOn, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Test run app component. /// /// Azure resource collection { resource id (fully qualified resource Id e.g /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) - /// : resource object } + /// : resource object } /// /// Test run identifier. /// The creation datetime(RFC 3339 literal format). @@ -715,9 +992,9 @@ public static ArtifactsContainerInfo ArtifactsContainerInfo(Uri uri = null, Date /// 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) + public static TestRunAppComponents TestRunAppComponents(IDictionary components = default, string testRunId = default, DateTimeOffset? createdDateTime = default, string createdBy = default, DateTimeOffset? lastModifiedDateTime = default, string lastModifiedBy = default) { - components ??= new Dictionary(); + components ??= new ChangeTrackingDictionary(); return new TestRunAppComponents( components, @@ -726,10 +1003,10 @@ public static TestRunAppComponents TestRunAppComponents(IDictionary Initializes a new instance of . + /// Test run server metrics configuration. /// Test run identifier. /// /// Azure resource metrics collection {metric id : metrics object} (Refer : @@ -741,9 +1018,9 @@ public static TestRunAppComponents TestRunAppComponents(IDictionary 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) + public static TestRunServerMetricsConfiguration TestRunServerMetricsConfiguration(string testRunId = default, IDictionary metrics = default, DateTimeOffset? createdDateTime = default, string createdBy = default, DateTimeOffset? lastModifiedDateTime = default, string lastModifiedBy = default) { - metrics ??= new Dictionary(); + metrics ??= new ChangeTrackingDictionary(); return new TestRunServerMetricsConfiguration( testRunId, @@ -752,20 +1029,20 @@ public static TestRunServerMetricsConfiguration TestRunServerMetricsConfiguratio createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Represents collection of metric definitions. /// the values for the metric definitions. /// A new instance for mocking. - public static MetricDefinitions MetricDefinitions(IEnumerable value = null) + public static MetricDefinitions MetricDefinitions(IEnumerable value = default) { - value ??= new List(); + value ??= new ChangeTrackingList(); - return new MetricDefinitions(value?.ToList(), serializedAdditionalRawData: null); + return new MetricDefinitions(value.ToList(), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Metric definition. /// List of dimensions. /// The metric description. /// The metric name. @@ -778,104 +1055,126 @@ public static MetricDefinitions MetricDefinitions(IEnumerable /// 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) + public static MetricDefinition MetricDefinition(IEnumerable dimensions = default, string description = default, string name = default, string @namespace = default, AggregationType? primaryAggregationType = default, IEnumerable supportedAggregationTypes = default, MetricUnit? unit = default, IEnumerable metricAvailabilities = default) { - dimensions ??= new List(); - supportedAggregationTypes ??= new List(); - metricAvailabilities ??= new List(); + dimensions ??= new ChangeTrackingList(); + supportedAggregationTypes ??= new ChangeTrackingList(); + metricAvailabilities ??= new ChangeTrackingList(); return new MetricDefinition( - dimensions?.ToList(), + dimensions.ToList(), description, name, @namespace, primaryAggregationType, - supportedAggregationTypes?.ToList(), + supportedAggregationTypes.ToList(), unit, - metricAvailabilities?.ToList(), - serializedAdditionalRawData: null); + metricAvailabilities.ToList(), + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// The name and description. /// The description. /// The name. /// A new instance for mocking. - public static NameAndDescription NameAndDescription(string description = null, string name = null) + public static NameAndDescription NameAndDescription(string description = default, string name = default) { - return new NameAndDescription(description, name, serializedAdditionalRawData: null); + return new NameAndDescription(description, name, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Metric availability specifies the time grain (aggregation interval or frequency). /// /// 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) + public static MetricAvailability MetricAvailability(TimeGrain? timeGrain = default) { - return new MetricAvailability(timeGrain, serializedAdditionalRawData: null); + return new MetricAvailability(timeGrain, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Represents collection of metric namespaces. /// The values for the metric namespaces. /// A new instance for mocking. - public static MetricNamespaces MetricNamespaces(IEnumerable value = null) + public static MetricNamespaces MetricNamespaces(IEnumerable value = default) { - value ??= new List(); + value ??= new ChangeTrackingList(); - return new MetricNamespaces(value?.ToList(), serializedAdditionalRawData: null); + return new MetricNamespaces(value.ToList(), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Metric namespace class specifies the metadata for a metric namespace. /// The namespace description. /// The metric namespace name. /// A new instance for mocking. - public static MetricNamespace MetricNamespace(string description = null, string name = null) + public static MetricNamespace MetricNamespace(string description = default, string name = default) + { + return new MetricNamespace(description, name, additionalBinaryDataProperties: null); + } + + /// Filters to fetch the set of metric. + /// + /// 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"} + /// + /// A new instance for mocking. + public static MetricsFilters MetricsFilters(IEnumerable filters = default) { - return new MetricNamespace(description, name, serializedAdditionalRawData: null); + filters ??= new ChangeTrackingList(); + + return new MetricsFilters(filters.ToList(), additionalBinaryDataProperties: null); + } + + /// Dimension name and values to filter. + /// The dimension name. + /// The dimension values. Maximum values can be 20. + /// A new instance for mocking. + public static DimensionFilter DimensionFilter(string name = default, IEnumerable values = default) + { + values ??= new ChangeTrackingList(); + + return new DimensionFilter(name, values.ToList(), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// The time series returned when a data query is performed. /// An array of data points representing the metric values. - /// The dimension values. + /// The dimension values . /// A new instance for mocking. - public static TimeSeriesElement TimeSeriesElement(IEnumerable data = null, IEnumerable dimensionValues = null) + public static TimeSeriesElement TimeSeriesElement(IEnumerable data = default, IEnumerable dimensionValues = default) { - data ??= new List(); - dimensionValues ??= new List(); + data ??= new ChangeTrackingList(); + dimensionValues ??= new ChangeTrackingList(); - return new TimeSeriesElement(data?.ToList(), dimensionValues?.ToList(), serializedAdditionalRawData: null); + return new TimeSeriesElement(data.ToList(), dimensionValues.ToList(), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Represents a metric value. /// 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) + public static MetricValue MetricValue(DateTimeOffset? timestamp = default, double? value = default) { - return new MetricValue(timestamp, value, serializedAdditionalRawData: null); + return new MetricValue(timestamp, value, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Represents a metric dimension value. /// 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) + public static DimensionValue DimensionValue(string name = default, string value = default) { - return new DimensionValue(name, value, serializedAdditionalRawData: null); + return new DimensionValue(name, value, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Test Profile Run model. /// 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 . - /// + /// Configurations of the target resource on which the test profile ran. /// 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). @@ -891,11 +1190,11 @@ public static DimensionValue DimensionValue(string name = null, string value = n /// 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) + public static TestProfileRun TestProfileRun(string testProfileRunId = default, string displayName = default, string description = default, string testProfileId = default, ResourceIdentifier targetResourceId = default, TargetResourceConfigurations targetResourceConfigurations = default, TestProfileRunStatus? status = default, IEnumerable errorDetails = default, DateTimeOffset? startDateTime = default, DateTimeOffset? endDateTime = default, long? durationInSeconds = default, IReadOnlyDictionary testRunDetails = default, IEnumerable recommendations = default, DateTimeOffset? createdDateTime = default, string createdBy = default, DateTimeOffset? lastModifiedDateTime = default, string lastModifiedBy = default) { - errorDetails ??= new List(); - testRunDetails ??= new Dictionary(); - recommendations ??= new List(); + errorDetails ??= new ChangeTrackingList(); + testRunDetails ??= new ChangeTrackingDictionary(); + recommendations ??= new ChangeTrackingList(); return new TestProfileRun( testProfileRunId, @@ -905,63 +1204,63 @@ public static TestProfileRun TestProfileRun(string testProfileRunId = null, stri targetResourceId, targetResourceConfigurations, status, - errorDetails?.ToList(), + errorDetails.ToList(), startDateTime, endDateTime, durationInSeconds, testRunDetails, - recommendations?.ToList(), + recommendations.ToList(), createdDateTime, createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Details of a particular test run for a test profile run. /// 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) + public static TestRunDetail TestRunDetail(TestRunStatus status = default, string configurationId = default, IDictionary properties = default) { - properties ??= new Dictionary(); + properties ??= new ChangeTrackingDictionary(); - return new TestRunDetail(status, configurationId, properties, serializedAdditionalRawData: null); + return new TestRunDetail(status, configurationId, properties, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// A recommendation object that provides a list of configuration that optimizes its category. /// 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) + public static TestProfileRunRecommendation TestProfileRunRecommendation(RecommendationCategory category = default, IEnumerable configurations = default) { - configurations ??= new List(); + configurations ??= new ChangeTrackingList(); - return new TestProfileRunRecommendation(category, configurations?.ToList(), serializedAdditionalRawData: null); + return new TestProfileRunRecommendation(category, configurations.ToList(), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Represents insights for the test run. /// The columns of the insights. /// The rows of the insights. /// The version of the insights. /// The status of the insights. /// A new instance for mocking. - public static TestRunInsights TestRunInsights(IEnumerable columns = null, IEnumerable> rows = null, long? version = null, OperationState? status = null) + public static TestRunInsights TestRunInsights(IEnumerable columns = default, IEnumerable> rows = default, long? version = default, OperationState? status = default) { - columns ??= new List(); - rows ??= new List>(); + columns ??= new ChangeTrackingList(); + rows ??= new ChangeTrackingList>(); - return new TestRunInsights(columns?.ToList(), rows?.ToList(), version, status, serializedAdditionalRawData: null); + return new TestRunInsights(columns.ToList(), rows.ToList(), version, status, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Represents a column of the test run insight. /// Name of the column. /// The data type of the column. /// A new instance for mocking. - public static TestRunInsightColumn TestRunInsightColumn(string name = null, string dataType = null) + public static TestRunInsightColumn TestRunInsightColumn(string name = default, string dataType = default) { - return new TestRunInsightColumn(name, dataType, serializedAdditionalRawData: null); + return new TestRunInsightColumn(name, dataType, additionalBinaryDataProperties: null); } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingRecurrence.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingRecurrence.Serialization.cs index 4d0f5414c81e..1010635de933 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingRecurrence.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingRecurrence.Serialization.cs @@ -8,15 +8,23 @@ using System; using System.ClientModel.Primitives; using System.Text.Json; -using Azure.Core; namespace Azure.Developer.LoadTesting { + /// + /// Recurrence model. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , , and . + /// [PersistableModelProxy(typeof(UnknownLoadTestingRecurrence))] - public partial class LoadTestingRecurrence : IUtf8JsonSerializable, IJsonModel + public abstract partial class LoadTestingRecurrence : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal LoadTestingRecurrence() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +36,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(LoadTestingRecurrence)} does not support writing '{format}' format."); } - writer.WritePropertyName("frequency"u8); writer.WriteStringValue(Frequency.ToString()); if (Optional.IsDefined(RecurrenceEnd)) @@ -41,15 +48,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("recurrenceEnd"u8); writer.WriteObjectValue(RecurrenceEnd, options); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -58,45 +65,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - LoadTestingRecurrence IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + LoadTestingRecurrence IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual LoadTestingRecurrence JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(LoadTestingRecurrence)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeLoadTestingRecurrence(document.RootElement, options); } - internal static LoadTestingRecurrence DeserializeLoadTestingRecurrence(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static LoadTestingRecurrence DeserializeLoadTestingRecurrence(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - if (element.TryGetProperty("frequency", out JsonElement discriminator)) + if (element.TryGetProperty("frequency"u8, 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); + case "Daily": + return DailyRecurrence.DeserializeDailyRecurrence(element, options); + case "Hourly": + return HourlyRecurrence.DeserializeHourlyRecurrence(element, options); + case "MonthlyByDays": + return MonthlyRecurrenceByWeekDays.DeserializeMonthlyRecurrenceByWeekDays(element, options); + case "MonthlyByDates": + return MonthlyRecurrenceByDates.DeserializeMonthlyRecurrenceByDates(element, options); + case "Cron": + return RecurrenceWithCron.DeserializeRecurrenceWithCron(element, options); + case "Weekly": + return WeeklyRecurrence.DeserializeWeeklyRecurrence(element, options); } } return UnknownLoadTestingRecurrence.DeserializeUnknownLoadTestingRecurrence(element, options); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -106,15 +127,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - LoadTestingRecurrence IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + LoadTestingRecurrence IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual LoadTestingRecurrence PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeLoadTestingRecurrence(document.RootElement, options); } default: @@ -122,22 +148,7 @@ LoadTestingRecurrence IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The response to deserialize the model from. - internal static LoadTestingRecurrence FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeLoadTestingRecurrence(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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingRecurrence.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingRecurrence.cs index 6544e925f7ba..4eafdf62ba0f 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingRecurrence.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingRecurrence.cs @@ -12,61 +12,34 @@ 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 . + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , , and . /// public abstract partial class LoadTestingRecurrence { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . - protected LoadTestingRecurrence() + /// Frequency of the recurrence. + private protected LoadTestingRecurrence(Frequency frequency) { + Frequency = frequency; } /// 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 LoadTestingRecurrence(Frequency frequency, RecurrenceEnd recurrenceEnd, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal LoadTestingRecurrence(Frequency frequency, RecurrenceEnd recurrenceEnd, IDictionary additionalBinaryDataProperties) { Frequency = frequency; RecurrenceEnd = recurrenceEnd; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingTrigger.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingTrigger.Serialization.cs index 95d1cff5cf04..527bcf97a758 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingTrigger.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingTrigger.Serialization.cs @@ -8,15 +8,24 @@ using System; using System.ClientModel.Primitives; using System.Text.Json; -using Azure.Core; +using Azure; namespace Azure.Developer.LoadTesting { + /// + /// Trigger model. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// [PersistableModelProxy(typeof(UnknownLoadTestingTrigger))] - public partial class LoadTestingTrigger : IUtf8JsonSerializable, IJsonModel + public abstract partial class LoadTestingTrigger : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal LoadTestingTrigger() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +37,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(LoadTestingTrigger)} does not support writing '{format}' format."); } - if (options.Format != "W") { writer.WritePropertyName("triggerId"u8); @@ -78,15 +86,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("lastModifiedBy"u8); writer.WriteStringValue(LastModifiedBy); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -95,40 +103,49 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - LoadTestingTrigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + LoadTestingTrigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual LoadTestingTrigger JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(LoadTestingTrigger)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeLoadTestingTrigger(document.RootElement, options); } - internal static LoadTestingTrigger DeserializeLoadTestingTrigger(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static LoadTestingTrigger DeserializeLoadTestingTrigger(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - if (element.TryGetProperty("kind", out JsonElement discriminator)) + if (element.TryGetProperty("kind"u8, out JsonElement discriminator)) { switch (discriminator.GetString()) { - case "ScheduleTestsTrigger": return ScheduleTestsTrigger.DeserializeScheduleTestsTrigger(element, options); + case "ScheduleTestsTrigger": + return ScheduleTestsTrigger.DeserializeScheduleTestsTrigger(element, options); } } return UnknownLoadTestingTrigger.DeserializeUnknownLoadTestingTrigger(element, options); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -138,15 +155,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - LoadTestingTrigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + LoadTestingTrigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual LoadTestingTrigger PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeLoadTestingTrigger(document.RootElement, options); } default: @@ -154,22 +176,14 @@ LoadTestingTrigger IPersistableModel.Create(BinaryData data, } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The response to deserialize the model from. - internal static LoadTestingTrigger FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeLoadTestingTrigger(document.RootElement); - } - - /// Convert into a . - internal virtual RequestContent ToRequestContent() + /// The to deserialize the from. + public static explicit operator LoadTestingTrigger(Response response) { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); - return content; + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeLoadTestingTrigger(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingTrigger.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingTrigger.cs index 87ba5d4260a7..0d820b9c2a15 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingTrigger.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/LoadTestingTrigger.cs @@ -12,51 +12,20 @@ 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 . + /// Please note this is the abstract base class. The derived classes available for instantiation are: . /// public abstract partial class LoadTestingTrigger { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// The name of the trigger. - /// is null. - protected LoadTestingTrigger(string displayName) + /// The type of the trigger. + private protected LoadTestingTrigger(string displayName, TriggerType kind) { - Argument.AssertNotNull(displayName, nameof(displayName)); - DisplayName = displayName; + Kind = kind; } /// Initializes a new instance of . @@ -70,8 +39,8 @@ protected LoadTestingTrigger(string displayName) /// 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 LoadTestingTrigger(string triggerId, string displayName, string description, TriggerType kind, TriggerState? state, StateDetails stateDetails, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal LoadTestingTrigger(string triggerId, string displayName, string description, TriggerType kind, TriggerState? state, StateDetails stateDetails, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary additionalBinaryDataProperties) { TriggerId = triggerId; DisplayName = displayName; @@ -83,32 +52,36 @@ internal LoadTestingTrigger(string triggerId, string displayName, string descrip CreatedBy = createdBy; LastModifiedDateTime = lastModifiedDateTime; LastModifiedBy = lastModifiedBy; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal LoadTestingTrigger() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricAvailability.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricAvailability.Serialization.cs index 9e445005c6a3..9ffd088c01d3 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricAvailability.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricAvailability.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Metric availability specifies the time grain (aggregation interval or frequency). + public partial class MetricAvailability : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,26 +28,25 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit /// 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; + string 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) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -56,53 +55,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - MetricAvailability IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + MetricAvailability IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MetricAvailability JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MetricAvailability DeserializeMetricAvailability(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("timeGrain"u8)) + if (prop.NameEquals("timeGrain"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - timeGrain = new TimeGrain(property.Value.GetString()); + timeGrain = new TimeGrain(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new MetricAvailability(timeGrain, serializedAdditionalRawData); + return new MetricAvailability(timeGrain, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -112,15 +117,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - MetricAvailability IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + MetricAvailability IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MetricAvailability PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeMetricAvailability(document.RootElement, options); } default: @@ -128,22 +138,7 @@ MetricAvailability IPersistableModel.Create(BinaryData data, } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricAvailability.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricAvailability.cs index 7634872e8667..960f3ddf1b16 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricAvailability.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricAvailability.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal MetricAvailability() @@ -55,11 +26,11 @@ internal MetricAvailability() /// 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) + /// Keeps track of any properties unknown to the library. + internal MetricAvailability(TimeGrain? timeGrain, IDictionary additionalBinaryDataProperties) { TimeGrain = timeGrain; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricDefinition.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricDefinition.Serialization.cs index 99ad9447041d..6da1f5c3a29c 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricDefinition.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricDefinition.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Metric definition. + public partial class MetricDefinition : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,17 +28,16 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter /// 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; + string 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) + foreach (NameAndDescription item in Dimensions) { writer.WriteObjectValue(item, options); } @@ -68,8 +67,13 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("supportedAggregationTypes"u8); writer.WriteStartArray(); - foreach (var item in SupportedAggregationTypes) + foreach (string item in SupportedAggregationTypes) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); @@ -83,21 +87,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("metricAvailabilities"u8); writer.WriteStartArray(); - foreach (var item in MetricAvailabilities) + foreach (MetricAvailability item in MetricAvailabilities) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -106,107 +110,118 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - MetricDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + MetricDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MetricDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MetricDefinition DeserializeMetricDefinition(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList dimensions = default; + IList dimensions = default; string description = default; string name = default; string @namespace = default; AggregationType? primaryAggregationType = default; - IReadOnlyList supportedAggregationTypes = default; + IList supportedAggregationTypes = default; MetricUnit? unit = default; - IReadOnlyList metricAvailabilities = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IList metricAvailabilities = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("dimensions"u8)) + if (prop.NameEquals("dimensions"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(NameAndDescription.DeserializeNameAndDescription(item, options)); } dimensions = array; continue; } - if (property.NameEquals("description"u8)) + if (prop.NameEquals("description"u8)) { - description = property.Value.GetString(); + description = prop.Value.GetString(); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("namespace"u8)) + if (prop.NameEquals("namespace"u8)) { - @namespace = property.Value.GetString(); + @namespace = prop.Value.GetString(); continue; } - if (property.NameEquals("primaryAggregationType"u8)) + if (prop.NameEquals("primaryAggregationType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - primaryAggregationType = new AggregationType(property.Value.GetString()); + primaryAggregationType = new AggregationType(prop.Value.GetString()); continue; } - if (property.NameEquals("supportedAggregationTypes"u8)) + if (prop.NameEquals("supportedAggregationTypes"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { - array.Add(item.GetString()); + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } } supportedAggregationTypes = array; continue; } - if (property.NameEquals("unit"u8)) + if (prop.NameEquals("unit"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - unit = new MetricUnit(property.Value.GetString()); + unit = new MetricUnit(prop.Value.GetString()); continue; } - if (property.NameEquals("metricAvailabilities"u8)) + if (prop.NameEquals("metricAvailabilities"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(MetricAvailability.DeserializeMetricAvailability(item, options)); } @@ -215,10 +230,9 @@ internal static MetricDefinition DeserializeMetricDefinition(JsonElement element } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new MetricDefinition( dimensions ?? new ChangeTrackingList(), description, @@ -228,13 +242,16 @@ internal static MetricDefinition DeserializeMetricDefinition(JsonElement element supportedAggregationTypes ?? new ChangeTrackingList(), unit, metricAvailabilities ?? new ChangeTrackingList(), - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -244,15 +261,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions op } } - MetricDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + MetricDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MetricDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeMetricDefinition(document.RootElement, options); } default: @@ -260,22 +282,7 @@ MetricDefinition IPersistableModel.Create(BinaryData data, Mod } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricDefinition.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricDefinition.cs index 7fb3baf52391..c293c1c39be5 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricDefinition.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricDefinition.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal MetricDefinition() @@ -65,8 +36,8 @@ internal MetricDefinition() /// 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) + /// Keeps track of any properties unknown to the library. + internal MetricDefinition(IList dimensions, string description, string name, string @namespace, AggregationType? primaryAggregationType, IList supportedAggregationTypes, MetricUnit? unit, IList metricAvailabilities, IDictionary additionalBinaryDataProperties) { Dimensions = dimensions; Description = description; @@ -76,27 +47,34 @@ internal MetricDefinition(IReadOnlyList dimensions, string d SupportedAggregationTypes = supportedAggregationTypes; Unit = unit; MetricAvailabilities = metricAvailabilities; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// List of dimensions. - public IReadOnlyList Dimensions { get; } + public IList 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; } + public IList 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; } + public IList MetricAvailabilities { get; } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricDefinitions.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricDefinitions.Serialization.cs index 5e2d9d689e8e..0a0017f17a21 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricDefinitions.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricDefinitions.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; namespace Azure.Developer.LoadTesting { - public partial class MetricDefinitions : IUtf8JsonSerializable, IJsonModel + /// Represents collection of metric definitions. + public partial class MetricDefinitions : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal MetricDefinitions() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,28 +34,27 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite /// 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; + string 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) + foreach (MetricDefinition item in Value) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -58,35 +63,39 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - MetricDefinitions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + MetricDefinitions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MetricDefinitions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MetricDefinitions DeserializeMetricDefinitions(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IList value = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(MetricDefinition.DeserializeMetricDefinition(item, options)); } @@ -95,17 +104,19 @@ internal static MetricDefinitions DeserializeMetricDefinitions(JsonElement eleme } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new MetricDefinitions(value, serializedAdditionalRawData); + return new MetricDefinitions(value, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -115,15 +126,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o } } - MetricDefinitions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + MetricDefinitions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MetricDefinitions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeMetricDefinitions(document.RootElement, options); } default: @@ -131,22 +147,14 @@ MetricDefinitions IPersistableModel.Create(BinaryData data, M } } + /// The client options for reading and writing models. 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() + /// The to deserialize the from. + public static explicit operator MetricDefinitions(Response response) { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); - return content; + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMetricDefinitions(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricDefinitions.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricDefinitions.cs index a33557916200..da621f868b4b 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricDefinitions.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricDefinitions.cs @@ -14,63 +14,26 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// 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) + /// Keeps track of any properties unknown to the library. + internal MetricDefinitions(IList value, IDictionary additionalBinaryDataProperties) { Value = value; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal MetricDefinitions() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// the values for the metric definitions. - public IReadOnlyList Value { get; } + public IList Value { get; } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricNamespace.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricNamespace.Serialization.cs index 62e6a24275ad..dd3637456a9c 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricNamespace.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricNamespace.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Metric namespace class specifies the metadata for a metric namespace. + public partial class MetricNamespace : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO /// 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; + string 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); @@ -44,15 +43,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,55 +60,61 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - MetricNamespace IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + MetricNamespace IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MetricNamespace JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MetricNamespace DeserializeMetricNamespace(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("description"u8)) + if (prop.NameEquals("description"u8)) { - description = property.Value.GetString(); + description = prop.Value.GetString(); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new MetricNamespace(description, name, serializedAdditionalRawData); + return new MetricNamespace(description, name, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -119,15 +124,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opt } } - MetricNamespace IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + MetricNamespace IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MetricNamespace PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeMetricNamespace(document.RootElement, options); } default: @@ -135,22 +145,7 @@ MetricNamespace IPersistableModel.Create(BinaryData data, Model } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricNamespace.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricNamespace.cs index 538d30c5e7bc..85f1d221b5b6 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricNamespace.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricNamespace.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal MetricNamespace() @@ -53,16 +24,17 @@ 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) + /// Keeps track of any properties unknown to the library. + internal MetricNamespace(string description, string name, IDictionary additionalBinaryDataProperties) { Description = description; Name = name; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The namespace description. public string Description { get; } + /// The metric namespace name. public string Name { get; } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricNamespaces.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricNamespaces.Serialization.cs index 5dffefef2de3..8edb81f87f1f 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricNamespaces.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricNamespaces.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; namespace Azure.Developer.LoadTesting { - public partial class MetricNamespaces : IUtf8JsonSerializable, IJsonModel + /// Represents collection of metric namespaces. + public partial class MetricNamespaces : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal MetricNamespaces() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,28 +34,27 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter /// 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; + string 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) + foreach (MetricNamespace item in Value) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -58,35 +63,39 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - MetricNamespaces IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + MetricNamespaces IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MetricNamespaces JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MetricNamespaces DeserializeMetricNamespaces(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IList value = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(MetricNamespace.DeserializeMetricNamespace(item, options)); } @@ -95,17 +104,19 @@ internal static MetricNamespaces DeserializeMetricNamespaces(JsonElement element } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new MetricNamespaces(value, serializedAdditionalRawData); + return new MetricNamespaces(value, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -115,15 +126,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions op } } - MetricNamespaces IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + MetricNamespaces IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MetricNamespaces PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeMetricNamespaces(document.RootElement, options); } default: @@ -131,22 +147,14 @@ MetricNamespaces IPersistableModel.Create(BinaryData data, Mod } } + /// The client options for reading and writing models. 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() + /// The to deserialize the from. + public static explicit operator MetricNamespaces(Response response) { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); - return content; + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMetricNamespaces(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricNamespaces.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricNamespaces.cs index f9f84c02c45d..5f27d400f343 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricNamespaces.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricNamespaces.cs @@ -14,63 +14,26 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// 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) + /// Keeps track of any properties unknown to the library. + internal MetricNamespaces(IList value, IDictionary additionalBinaryDataProperties) { Value = value; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal MetricNamespaces() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The values for the metric namespaces. - public IReadOnlyList Value { get; } + public IList Value { get; } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricUnit.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricUnit.cs index d64f0709ccd2..3b3279bb8212 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricUnit.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricUnit.cs @@ -14,56 +14,87 @@ namespace Azure.Developer.LoadTesting 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)); - } - + /// No unit specified. private const string NotSpecifiedValue = "NotSpecified"; + /// Percentage. private const string PercentValue = "Percent"; + /// Value count. private const string CountValue = "Count"; + /// Seconds. private const string SecondsValue = "Seconds"; + /// Milliseconds. private const string MillisecondsValue = "Milliseconds"; + /// Bytes. private const string BytesValue = "Bytes"; + /// Bytes per second. private const string BytesPerSecondValue = "BytesPerSecond"; + /// Count per second. private const string CountPerSecondValue = "CountPerSecond"; + /// Initializes a new instance of . + /// The value. + /// is null. + public MetricUnit(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(MetricUnit left, MetricUnit right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(MetricUnit left, MetricUnit right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator MetricUnit(string value) => new MetricUnit(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator MetricUnit?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricValue.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricValue.Serialization.cs index a3da9d179918..98c138ac6966 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricValue.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricValue.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Represents a metric value. + public partial class MetricValue : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptio /// 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; + string 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); @@ -44,15 +43,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("value"u8); writer.WriteNumberValue(Value.Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,63 +60,69 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - MetricValue IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + MetricValue IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MetricValue JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MetricValue DeserializeMetricValue(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("timestamp"u8)) + if (prop.NameEquals("timestamp"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - timestamp = property.Value.GetDateTimeOffset("O"); + timestamp = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - value = property.Value.GetDouble(); + value = prop.Value.GetDouble(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new MetricValue(timestamp, value, serializedAdditionalRawData); + return new MetricValue(timestamp, value, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -127,15 +132,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options } } - MetricValue IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + MetricValue IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MetricValue PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeMetricValue(document.RootElement, options); } default: @@ -143,22 +153,7 @@ MetricValue IPersistableModel.Create(BinaryData data, ModelReaderWr } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricValue.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricValue.cs index e82fbc986e03..a69b6dfa12ad 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricValue.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricValue.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal MetricValue() @@ -53,16 +24,17 @@ 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) + /// Keeps track of any properties unknown to the library. + internal MetricValue(DateTimeOffset? timestamp, double? value, IDictionary additionalBinaryDataProperties) { Timestamp = timestamp; Value = value; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Metrics.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Metrics.Serialization.cs new file mode 100644 index 000000000000..323c1738fa01 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Metrics.Serialization.cs @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; + +namespace Azure.Developer.LoadTesting +{ + /// The response to a metrics query. + internal partial class Metrics : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal Metrics() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + 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) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Metrics)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (TimeSeriesElement item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + Metrics IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual Metrics JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Metrics)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetrics(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static Metrics DeserializeMetrics(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(TimeSeriesElement.DeserializeTimeSeriesElement(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new Metrics(value, nextLink, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureDeveloperLoadTestingContext.Default); + default: + throw new FormatException($"The model {nameof(Metrics)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + Metrics IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual Metrics PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMetrics(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Metrics)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator Metrics(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMetrics(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Metrics.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Metrics.cs new file mode 100644 index 000000000000..b9782e691c70 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Metrics.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.Developer.LoadTesting +{ + /// The response to a metrics query. + internal partial class Metrics + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The TimeSeriesElement items on this page. + internal Metrics(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The TimeSeriesElement items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal Metrics(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The TimeSeriesElement items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricsFilters.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricsFilters.Serialization.cs index bece7a2e9b31..c59530762b1d 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricsFilters.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricsFilters.Serialization.cs @@ -13,10 +13,11 @@ namespace Azure.Developer.LoadTesting { - public partial class MetricsFilters : IUtf8JsonSerializable, IJsonModel + /// Filters to fetch the set of metric. + public partial class MetricsFilters : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,31 +29,30 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp /// 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; + string 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) + foreach (DimensionFilter item in Filters) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,39 +61,43 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - MetricsFilters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + MetricsFilters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MetricsFilters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MetricsFilters DeserializeMetricsFilters(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("filters"u8)) + if (prop.NameEquals("filters"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(DimensionFilter.DeserializeDimensionFilter(item, options)); } @@ -102,17 +106,19 @@ internal static MetricsFilters DeserializeMetricsFilters(JsonElement element, Mo } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new MetricsFilters(filters ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new MetricsFilters(filters ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -122,15 +128,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opti } } - MetricsFilters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + MetricsFilters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MetricsFilters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeMetricsFilters(document.RootElement, options); } default: @@ -138,21 +149,18 @@ MetricsFilters IPersistableModel.Create(BinaryData data, ModelRe } } + /// The client options for reading and writing models. 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) + /// The to serialize into . + public static implicit operator RequestContent(MetricsFilters metricsFilters) { - 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); + if (metricsFilters == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(metricsFilters, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricsFilters.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricsFilters.cs index b31007e96aef..518c0cd60d6c 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricsFilters.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MetricsFilters.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public MetricsFilters() @@ -58,11 +29,11 @@ public MetricsFilters() /// 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) + /// Keeps track of any properties unknown to the library. + internal MetricsFilters(IList filters, IDictionary additionalBinaryDataProperties) { Filters = filters; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Models/AzureDeveloperLoadTestingContext.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Models/AzureDeveloperLoadTestingContext.cs index 6ec1ba20d4b9..2b61e950d08b 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Models/AzureDeveloperLoadTestingContext.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/Models/AzureDeveloperLoadTestingContext.cs @@ -6,12 +6,13 @@ #nullable disable using System.ClientModel.Primitives; +using Azure; namespace Azure.Developer.LoadTesting { /// /// Context class which will be filled in by the System.ClientModel.SourceGeneration. - /// For more information see 'https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/src/docs/ModelReaderWriterContext.md' + /// For more information /// [ModelReaderWriterBuildable(typeof(ArtifactsContainerInfo))] [ModelReaderWriterBuildable(typeof(AutoStopCriteria))] @@ -19,6 +20,7 @@ namespace Azure.Developer.LoadTesting [ModelReaderWriterBuildable(typeof(DailyRecurrence))] [ModelReaderWriterBuildable(typeof(DimensionFilter))] [ModelReaderWriterBuildable(typeof(DimensionValue))] + [ModelReaderWriterBuildable(typeof(DimensionValueList))] [ModelReaderWriterBuildable(typeof(ErrorDetails))] [ModelReaderWriterBuildable(typeof(FunctionFlexConsumptionResourceConfiguration))] [ModelReaderWriterBuildable(typeof(FunctionFlexConsumptionTargetResourceConfigurations))] @@ -34,6 +36,7 @@ namespace Azure.Developer.LoadTesting [ModelReaderWriterBuildable(typeof(MetricDefinitions))] [ModelReaderWriterBuildable(typeof(MetricNamespace))] [ModelReaderWriterBuildable(typeof(MetricNamespaces))] + [ModelReaderWriterBuildable(typeof(Metrics))] [ModelReaderWriterBuildable(typeof(MetricsFilters))] [ModelReaderWriterBuildable(typeof(MetricValue))] [ModelReaderWriterBuildable(typeof(MonthlyRecurrenceByDates))] @@ -42,6 +45,13 @@ namespace Azure.Developer.LoadTesting [ModelReaderWriterBuildable(typeof(NotificationRule))] [ModelReaderWriterBuildable(typeof(OperationStatus))] [ModelReaderWriterBuildable(typeof(OptionalLoadTestConfiguration))] + [ModelReaderWriterBuildable(typeof(PagedNotificationRule))] + [ModelReaderWriterBuildable(typeof(PagedTest))] + [ModelReaderWriterBuildable(typeof(PagedTestFileInfo))] + [ModelReaderWriterBuildable(typeof(PagedTestProfile))] + [ModelReaderWriterBuildable(typeof(PagedTestProfileRun))] + [ModelReaderWriterBuildable(typeof(PagedTestRun))] + [ModelReaderWriterBuildable(typeof(PagedTrigger))] [ModelReaderWriterBuildable(typeof(PassFailCriteria))] [ModelReaderWriterBuildable(typeof(PassFailMetric))] [ModelReaderWriterBuildable(typeof(PassFailServerMetric))] diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByDates.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByDates.Serialization.cs index 91758cc0bb2a..c631a7e9cc76 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByDates.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByDates.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Recurrence model when frequency is set as MonthlyByDates. + public partial class MonthlyRecurrenceByDates : LoadTestingRecurrence, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,18 +28,17 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead /// 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; + string 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) + foreach (int item in DatesInMonth) { writer.WriteNumberValue(item); } @@ -52,84 +51,90 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - MonthlyRecurrenceByDates IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + MonthlyRecurrenceByDates IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (MonthlyRecurrenceByDates)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override LoadTestingRecurrence JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MonthlyRecurrenceByDates DeserializeMonthlyRecurrenceByDates(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList datesInMonth = default; + int? interval = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("datesInMonth"u8)) + if (prop.NameEquals("frequency"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; + frequency = new Frequency(prop.Value.GetString()); continue; } - if (property.NameEquals("interval"u8)) + if (prop.NameEquals("recurrenceEnd"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - interval = property.Value.GetInt32(); + recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(prop.Value, options); continue; } - if (property.NameEquals("frequency"u8)) + if (prop.NameEquals("datesInMonth"u8)) { - frequency = new Frequency(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(item.GetInt32()); + } + datesInMonth = array; continue; } - if (property.NameEquals("recurrenceEnd"u8)) + if (prop.NameEquals("interval"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(property.Value, options); + interval = prop.Value.GetInt32(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new MonthlyRecurrenceByDates(frequency, recurrenceEnd, serializedAdditionalRawData, datesInMonth ?? new ChangeTrackingList(), interval); + return new MonthlyRecurrenceByDates(frequency, recurrenceEnd, additionalBinaryDataProperties, datesInMonth ?? new ChangeTrackingList(), interval); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -139,15 +144,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp } } - MonthlyRecurrenceByDates IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + MonthlyRecurrenceByDates IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (MonthlyRecurrenceByDates)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override LoadTestingRecurrence PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeMonthlyRecurrenceByDates(document.RootElement, options); } default: @@ -155,22 +165,7 @@ MonthlyRecurrenceByDates IPersistableModel.Create(Bina } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByDates.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByDates.cs index 5274acd5de88..a0fe16f8653b 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByDates.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByDates.cs @@ -14,19 +14,18 @@ namespace Azure.Developer.LoadTesting public partial class MonthlyRecurrenceByDates : LoadTestingRecurrence { /// Initializes a new instance of . - public MonthlyRecurrenceByDates() + public MonthlyRecurrenceByDates() : base(Frequency.MonthlyByDates) { - 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. + /// 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) + internal MonthlyRecurrenceByDates(Frequency frequency, RecurrenceEnd recurrenceEnd, IDictionary additionalBinaryDataProperties, IList datesInMonth, int? interval) : base(frequency, recurrenceEnd, additionalBinaryDataProperties) { DatesInMonth = datesInMonth; Interval = interval; @@ -34,6 +33,7 @@ internal MonthlyRecurrenceByDates(Frequency frequency, RecurrenceEnd recurrenceE /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByWeekDays.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByWeekDays.Serialization.cs index 10ad327a0de0..227b37bd27f6 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByWeekDays.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByWeekDays.Serialization.cs @@ -9,14 +9,19 @@ 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 + /// Recurrence model when frequency is set as MonthlyByDays . + public partial class MonthlyRecurrenceByWeekDays : LoadTestingRecurrence, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal MonthlyRecurrenceByWeekDays() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,18 +33,17 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR /// 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; + string 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) + foreach (WeekDays item in WeekDaysInMonth) { writer.WriteStringValue(item.ToString()); } @@ -51,92 +55,98 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteNumberValue(Interval); } - MonthlyRecurrenceByWeekDays IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + MonthlyRecurrenceByWeekDays IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (MonthlyRecurrenceByWeekDays)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override LoadTestingRecurrence JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MonthlyRecurrenceByWeekDays DeserializeMonthlyRecurrenceByWeekDays(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + Frequency frequency = default; + RecurrenceEnd recurrenceEnd = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); 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()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("weekDaysInMonth"u8)) + if (prop.NameEquals("frequency"u8)) + { + frequency = new Frequency(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("recurrenceEnd"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(prop.Value, options); + continue; + } + if (prop.NameEquals("weekDaysInMonth"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(new WeekDays(item.GetString())); } weekDaysInMonth = array; continue; } - if (property.NameEquals("index"u8)) + if (prop.NameEquals("index"u8)) { - index = property.Value.GetInt32(); + index = prop.Value.GetInt32(); continue; } - if (property.NameEquals("interval"u8)) + if (prop.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); + interval = prop.Value.GetInt32(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new MonthlyRecurrenceByWeekDays( frequency, recurrenceEnd, - serializedAdditionalRawData, + additionalBinaryDataProperties, weekDaysInMonth ?? new ChangeTrackingList(), index, interval); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -146,15 +156,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrite } } - MonthlyRecurrenceByWeekDays IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + MonthlyRecurrenceByWeekDays IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (MonthlyRecurrenceByWeekDays)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override LoadTestingRecurrence PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeMonthlyRecurrenceByWeekDays(document.RootElement, options); } default: @@ -162,22 +177,7 @@ MonthlyRecurrenceByWeekDays IPersistableModel.Creat } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByWeekDays.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByWeekDays.cs index 80d15441c93f..940f50120775 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByWeekDays.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/MonthlyRecurrenceByWeekDays.cs @@ -16,9 +16,8 @@ public partial class MonthlyRecurrenceByWeekDays : LoadTestingRecurrence /// 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) + public MonthlyRecurrenceByWeekDays(int index, int interval) : base(Frequency.MonthlyByDays) { - Frequency = Frequency.MonthlyByDays; WeekDaysInMonth = new ChangeTrackingList(); Index = index; Interval = interval; @@ -27,26 +26,23 @@ public MonthlyRecurrenceByWeekDays(int index, int 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. + /// 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) + internal MonthlyRecurrenceByWeekDays(Frequency frequency, RecurrenceEnd recurrenceEnd, IDictionary additionalBinaryDataProperties, IList weekDaysInMonth, int index, int interval) : base(frequency, recurrenceEnd, additionalBinaryDataProperties) { 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NameAndDescription.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NameAndDescription.Serialization.cs index 2f128a9b1cc9..d2dace528eec 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NameAndDescription.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NameAndDescription.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// The name and description. + public partial class NameAndDescription : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit /// 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; + string 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); @@ -44,15 +43,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,55 +60,61 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - NameAndDescription IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + NameAndDescription IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual NameAndDescription JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static NameAndDescription DeserializeNameAndDescription(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("description"u8)) + if (prop.NameEquals("description"u8)) { - description = property.Value.GetString(); + description = prop.Value.GetString(); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new NameAndDescription(description, name, serializedAdditionalRawData); + return new NameAndDescription(description, name, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -119,15 +124,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - NameAndDescription IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + NameAndDescription IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual NameAndDescription PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeNameAndDescription(document.RootElement, options); } default: @@ -135,22 +145,7 @@ NameAndDescription IPersistableModel.Create(BinaryData data, } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NameAndDescription.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NameAndDescription.cs index 3669d22e4369..2076c1c927bb 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NameAndDescription.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NameAndDescription.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal NameAndDescription() @@ -53,16 +24,17 @@ 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) + /// Keeps track of any properties unknown to the library. + internal NameAndDescription(string description, string name, IDictionary additionalBinaryDataProperties) { Description = description; Name = name; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The description. public string Description { get; } + /// The name. public string Name { get; } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NotificationEventType.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NotificationEventType.cs index 48b21c47df11..4a6f7b27b362 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NotificationEventType.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NotificationEventType.cs @@ -14,44 +14,67 @@ namespace Azure.Developer.LoadTesting internal readonly partial struct NotificationEventType : IEquatable { private readonly string _value; + /// Test run ended event. This event would occur when a test run reaches terminal state. + private const string TestRunEndedValue = "TestRunEnded"; + /// Test run started event. This event would occur when a new test run is triggered. + private const string TestRunStartedValue = "TestRunStarted"; + /// Trigger completed event. This event would occur when a trigger completes. + private const string TriggerCompletedValue = "TriggerCompleted"; + /// Trigger disabled event. This event would occur when a trigger is disabled. + private const string TriggerDisabledValue = "TriggerDisabled"; /// Initializes a new instance of . + /// The value. /// is null. public NotificationEventType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string TestRunEndedValue = "TestRunEnded"; - private const string TestRunStartedValue = "TestRunStarted"; - private const string TriggerCompletedValue = "TriggerCompleted"; - private const string TriggerDisabledValue = "TriggerDisabled"; + _value = value; + } /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(NotificationEventType left, NotificationEventType right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(NotificationEventType left, NotificationEventType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator NotificationEventType(string value) => new NotificationEventType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator NotificationEventType?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NotificationRule.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NotificationRule.Serialization.cs index 10402e2ee69e..8e246fdbe77c 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NotificationRule.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NotificationRule.Serialization.cs @@ -8,15 +8,24 @@ using System; using System.ClientModel.Primitives; using System.Text.Json; -using Azure.Core; +using Azure; namespace Azure.Developer.LoadTesting { + /// + /// Notification rule model. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// [PersistableModelProxy(typeof(UnknownNotificationRule))] - public partial class NotificationRule : IUtf8JsonSerializable, IJsonModel + public abstract partial class NotificationRule : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal NotificationRule() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +37,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter /// 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; + string 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); @@ -43,8 +51,13 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WriteStringValue(DisplayName); writer.WritePropertyName("actionGroupIds"u8); writer.WriteStartArray(); - foreach (var item in ActionGroupIds) + foreach (string item in ActionGroupIds) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); @@ -70,15 +83,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("lastModifiedBy"u8); writer.WriteStringValue(LastModifiedBy); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -87,40 +100,49 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - NotificationRule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + NotificationRule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual NotificationRule JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static NotificationRule DeserializeNotificationRule(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - if (element.TryGetProperty("scope", out JsonElement discriminator)) + if (element.TryGetProperty("scope"u8, out JsonElement discriminator)) { switch (discriminator.GetString()) { - case "Tests": return TestsNotificationRule.DeserializeTestsNotificationRule(element, options); + 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; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -130,15 +152,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions op } } - NotificationRule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + NotificationRule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual NotificationRule PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeNotificationRule(document.RootElement, options); } default: @@ -146,22 +173,14 @@ NotificationRule IPersistableModel.Create(BinaryData data, Mod } } + /// The client options for reading and writing models. 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() + /// The to deserialize the from. + public static explicit operator NotificationRule(Response response) { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); - return content; + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNotificationRule(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NotificationRule.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NotificationRule.cs index ceb4f13074b9..695e147a1c58 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NotificationRule.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NotificationRule.cs @@ -13,54 +13,22 @@ 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 . + /// Please note this is the abstract base class. The derived classes available for instantiation are: . /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// 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) + /// The scope of the notification rule. + private protected NotificationRule(string displayName, IEnumerable actionGroupIds, NotificationScopeType scope) { - Argument.AssertNotNull(displayName, nameof(displayName)); - Argument.AssertNotNull(actionGroupIds, nameof(actionGroupIds)); - DisplayName = displayName; ActionGroupIds = actionGroupIds.ToList(); + Scope = scope; } /// Initializes a new instance of . @@ -72,8 +40,8 @@ protected NotificationRule(string displayName, IEnumerable actionGroupId /// 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) + /// 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 additionalBinaryDataProperties) { NotificationRuleId = notificationRuleId; DisplayName = displayName; @@ -83,28 +51,30 @@ internal NotificationRule(string notificationRuleId, string displayName, IList Initializes a new instance of for deserialization. - internal NotificationRule() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NotificationScopeType.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NotificationScopeType.cs index c0d611e90f35..4c1e9b1dff64 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NotificationScopeType.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/NotificationScopeType.cs @@ -14,35 +14,52 @@ namespace Azure.Developer.LoadTesting internal readonly partial struct NotificationScopeType : IEquatable { private readonly string _value; + /// Notification rule is for Tests. + private const string TestsValue = "Tests"; /// Initializes a new instance of . + /// The value. /// is null. public NotificationScopeType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string TestsValue = "Tests"; + _value = value; + } /// Notification rule is for Tests. public static NotificationScopeType Tests { get; } = new NotificationScopeType(TestsValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(NotificationScopeType left, NotificationScopeType right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(NotificationScopeType left, NotificationScopeType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator NotificationScopeType(string value) => new NotificationScopeType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator NotificationScopeType?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OperationKind.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OperationKind.cs index f8cdc79b6623..8ce507d97a0b 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OperationKind.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OperationKind.cs @@ -14,38 +14,57 @@ namespace Azure.Developer.LoadTesting public readonly partial struct OperationKind : IEquatable { private readonly string _value; + /// Operation represents a clone test operation. + private const string CloneTestValue = "CloneTest"; + /// Operation represents a test run insights generation operation. + private const string GenerateTestRunInsightsValue = "GenerateTestRunInsights"; /// Initializes a new instance of . + /// The value. /// is null. public OperationKind(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string CloneTestValue = "CloneTest"; - private const string GenerateTestRunInsightsValue = "GenerateTestRunInsights"; + _value = value; + } /// Operation represents a clone test operation. public static OperationKind CloneTest { get; } = new OperationKind(CloneTestValue); + /// Operation represents a test run insights generation operation. public static OperationKind GenerateTestRunInsights { get; } = new OperationKind(GenerateTestRunInsightsValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(OperationKind left, OperationKind right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(OperationKind left, OperationKind right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator OperationKind(string value) => new OperationKind(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator OperationKind?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OperationState.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OperationState.cs index 4ecb60454dcd..fca35aab1823 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OperationState.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OperationState.cs @@ -14,47 +14,72 @@ namespace Azure.Developer.LoadTesting public readonly partial struct OperationState : IEquatable { private readonly string _value; + /// The operation has not started. + private const string NotStartedValue = "NotStarted"; + /// The operation is in progress. + private const string RunningValue = "Running"; + /// The operation has completed successfully. + private const string SucceededValue = "Succeeded"; + /// The operation has failed. + private const string FailedValue = "Failed"; + /// The operation has been canceled by the user. + private const string CanceledValue = "Canceled"; /// Initializes a new instance of . + /// The value. /// is null. public OperationState(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, 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"; + _value = value; + } /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(OperationState left, OperationState right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(OperationState left, OperationState right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator OperationState(string value) => new OperationState(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator OperationState?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OperationStatus.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OperationStatus.Serialization.cs index 82cc95c73d96..4d19e12f0904 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OperationStatus.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OperationStatus.Serialization.cs @@ -10,14 +10,20 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; -using Azure.Core; +using Azure; namespace Azure.Developer.LoadTesting { - public partial class OperationStatus : IUtf8JsonSerializable, IJsonModel + /// Status of a long running operation. + public partial class OperationStatus : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal OperationStatus() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -29,12 +35,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO /// 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; + string 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."); } - if (options.Format != "W") { writer.WritePropertyName("id"u8); @@ -49,15 +54,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("error"u8); ((IJsonModel)Error).Write(writer, options); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -66,22 +71,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - OperationStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + OperationStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual OperationStatus JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OperationStatus DeserializeOperationStatus(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -90,47 +100,48 @@ internal static OperationStatus DeserializeOperationStatus(JsonElement element, OperationState status = default; OperationKind kind = default; ResponseError error = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - id = property.Value.GetString(); + id = prop.Value.GetString(); continue; } - if (property.NameEquals("status"u8)) + if (prop.NameEquals("status"u8)) { - status = new OperationState(property.Value.GetString()); + status = new OperationState(prop.Value.GetString()); continue; } - if (property.NameEquals("kind"u8)) + if (prop.NameEquals("kind"u8)) { - kind = new OperationKind(property.Value.GetString()); + kind = new OperationKind(prop.Value.GetString()); continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("error"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureDeveloperLoadTestingContext.Default); + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), options, AzureDeveloperLoadTestingContext.Default); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new OperationStatus(id, status, kind, error, serializedAdditionalRawData); + return new OperationStatus(id, status, kind, error, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -140,15 +151,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opt } } - OperationStatus IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + OperationStatus IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual OperationStatus PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeOperationStatus(document.RootElement, options); } default: @@ -156,22 +172,14 @@ OperationStatus IPersistableModel.Create(BinaryData data, Model } } + /// The client options for reading and writing models. 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() + /// The to deserialize the from. + public static explicit operator OperationStatus(Response response) { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); - return content; + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOperationStatus(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OperationStatus.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OperationStatus.cs index a50b0503bfe9..ccbc4ef31bcc 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OperationStatus.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OperationStatus.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure; 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// The state of the operation. @@ -59,27 +31,25 @@ internal OperationStatus(OperationState status, OperationKind kind) /// The state of the operation. /// The kind of the operation. /// Error object that describes the error when status is "Failed". - /// Keeps track of any properties unknown to the library. - internal OperationStatus(string id, OperationState status, OperationKind kind, ResponseError error, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal OperationStatus(string id, OperationState status, OperationKind kind, ResponseError error, IDictionary additionalBinaryDataProperties) { Id = id; Status = status; Kind = kind; Error = error; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal OperationStatus() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The unique ID of the operation. public string Id { get; } + /// 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; } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OptionalLoadTestConfiguration.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OptionalLoadTestConfiguration.Serialization.cs index 677e7c9cf313..959e05d2a283 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OptionalLoadTestConfiguration.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OptionalLoadTestConfiguration.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Configuration for quick load test. + public partial class OptionalLoadTestConfiguration : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode /// 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; + string 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); @@ -62,17 +61,17 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (Optional.IsDefined(Duration)) { writer.WritePropertyName("duration"u8); - writer.WriteNumberValue(Convert.ToInt32(Duration.Value.ToString("%s"))); + writer.WriteNumberValue(Convert.ToInt32(Duration.Value.TotalSeconds)); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -81,110 +80,116 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - OptionalLoadTestConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + OptionalLoadTestConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual OptionalLoadTestConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OptionalLoadTestConfiguration DeserializeOptionalLoadTestConfiguration(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - Uri endpointUrl = default; + Uri endpointUri = 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("endpointUrl"u8)) + if (prop.NameEquals("endpointUrl"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - endpointUrl = new Uri(property.Value.GetString()); + endpointUri = new Uri(prop.Value.GetString()); continue; } - if (property.NameEquals("requestsPerSecond"u8)) + if (prop.NameEquals("requestsPerSecond"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - requestsPerSecond = property.Value.GetInt32(); + requestsPerSecond = prop.Value.GetInt32(); continue; } - if (property.NameEquals("maxResponseTimeInMs"u8)) + if (prop.NameEquals("maxResponseTimeInMs"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - maxResponseTimeInMs = property.Value.GetInt32(); + maxResponseTimeInMs = prop.Value.GetInt32(); continue; } - if (property.NameEquals("virtualUsers"u8)) + if (prop.NameEquals("virtualUsers"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - virtualUsers = property.Value.GetInt32(); + virtualUsers = prop.Value.GetInt32(); continue; } - if (property.NameEquals("rampUpTime"u8)) + if (prop.NameEquals("rampUpTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - rampUpTime = property.Value.GetInt32(); + rampUpTime = prop.Value.GetInt32(); continue; } - if (property.NameEquals("duration"u8)) + if (prop.NameEquals("duration"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - duration = TimeSpan.FromSeconds(property.Value.GetInt32()); + duration = TimeSpan.FromSeconds(prop.Value.GetInt32()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new OptionalLoadTestConfiguration( - endpointUrl, + endpointUri, requestsPerSecond, maxResponseTimeInMs, virtualUsers, rampUpTime, duration, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -194,15 +199,20 @@ BinaryData IPersistableModel.Write(ModelReaderWri } } - OptionalLoadTestConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + OptionalLoadTestConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual OptionalLoadTestConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeOptionalLoadTestConfiguration(document.RootElement, options); } default: @@ -210,22 +220,7 @@ OptionalLoadTestConfiguration IPersistableModel.C } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OptionalLoadTestConfiguration.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OptionalLoadTestConfiguration.cs index 1fe5782307a2..c123a5a29265 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OptionalLoadTestConfiguration.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/OptionalLoadTestConfiguration.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public OptionalLoadTestConfiguration() @@ -57,8 +28,8 @@ public OptionalLoadTestConfiguration() /// 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) + /// Keeps track of any properties unknown to the library. + internal OptionalLoadTestConfiguration(Uri endpointUri, int? requestsPerSecond, int? maxResponseTimeInMs, int? virtualUsers, int? rampUpTime, TimeSpan? duration, IDictionary additionalBinaryDataProperties) { EndpointUri = endpointUri; RequestsPerSecond = requestsPerSecond; @@ -66,19 +37,24 @@ internal OptionalLoadTestConfiguration(Uri endpointUri, int? requestsPerSecond, VirtualUsers = virtualUsers; RampUpTime = rampUpTime; Duration = duration; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedNotificationRule.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedNotificationRule.Serialization.cs new file mode 100644 index 000000000000..e867275ee1e4 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedNotificationRule.Serialization.cs @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; + +namespace Azure.Developer.LoadTesting +{ + /// Paged collection of NotificationRule items. + internal partial class PagedNotificationRule : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PagedNotificationRule() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + 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) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedNotificationRule)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (NotificationRule item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + PagedNotificationRule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PagedNotificationRule JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedNotificationRule)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePagedNotificationRule(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PagedNotificationRule DeserializePagedNotificationRule(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(NotificationRule.DeserializeNotificationRule(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PagedNotificationRule(value, nextLink, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureDeveloperLoadTestingContext.Default); + default: + throw new FormatException($"The model {nameof(PagedNotificationRule)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + PagedNotificationRule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PagedNotificationRule PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePagedNotificationRule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PagedNotificationRule)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator PagedNotificationRule(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePagedNotificationRule(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedNotificationRule.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedNotificationRule.cs new file mode 100644 index 000000000000..90acce6b9b9e --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedNotificationRule.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.Developer.LoadTesting +{ + /// Paged collection of NotificationRule items. + internal partial class PagedNotificationRule + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The NotificationRule items on this page. + internal PagedNotificationRule(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The NotificationRule items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal PagedNotificationRule(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The NotificationRule items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTest.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTest.Serialization.cs new file mode 100644 index 000000000000..5af8c430ab99 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTest.Serialization.cs @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; + +namespace Azure.Developer.LoadTesting +{ + /// Paged collection of Test items. + internal partial class PagedTest : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PagedTest() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + 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) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedTest)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (LoadTest item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + PagedTest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PagedTest JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedTest)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePagedTest(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PagedTest DeserializePagedTest(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(LoadTest.DeserializeLoadTest(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PagedTest(value, nextLink, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureDeveloperLoadTestingContext.Default); + default: + throw new FormatException($"The model {nameof(PagedTest)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + PagedTest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PagedTest PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePagedTest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PagedTest)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator PagedTest(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePagedTest(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTest.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTest.cs new file mode 100644 index 000000000000..1af790f0f9e1 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTest.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.Developer.LoadTesting +{ + /// Paged collection of Test items. + internal partial class PagedTest + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The Test items on this page. + internal PagedTest(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The Test items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal PagedTest(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The Test items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestFileInfo.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestFileInfo.Serialization.cs new file mode 100644 index 000000000000..45d793e802ef --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestFileInfo.Serialization.cs @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; + +namespace Azure.Developer.LoadTesting +{ + /// Paged collection of TestFileInfo items. + internal partial class PagedTestFileInfo : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PagedTestFileInfo() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + 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) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedTestFileInfo)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (TestFileInfo item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + PagedTestFileInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PagedTestFileInfo JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedTestFileInfo)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePagedTestFileInfo(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PagedTestFileInfo DeserializePagedTestFileInfo(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(TestFileInfo.DeserializeTestFileInfo(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PagedTestFileInfo(value, nextLink, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureDeveloperLoadTestingContext.Default); + default: + throw new FormatException($"The model {nameof(PagedTestFileInfo)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + PagedTestFileInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PagedTestFileInfo PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePagedTestFileInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PagedTestFileInfo)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator PagedTestFileInfo(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePagedTestFileInfo(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestFileInfo.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestFileInfo.cs new file mode 100644 index 000000000000..0d278c427870 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestFileInfo.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.Developer.LoadTesting +{ + /// Paged collection of TestFileInfo items. + internal partial class PagedTestFileInfo + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The TestFileInfo items on this page. + internal PagedTestFileInfo(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The TestFileInfo items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal PagedTestFileInfo(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The TestFileInfo items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestProfile.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestProfile.Serialization.cs new file mode 100644 index 000000000000..7d04f16153b8 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestProfile.Serialization.cs @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; + +namespace Azure.Developer.LoadTesting +{ + /// Paged collection of TestProfile items. + internal partial class PagedTestProfile : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PagedTestProfile() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + 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) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedTestProfile)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (TestProfile item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + PagedTestProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PagedTestProfile JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedTestProfile)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePagedTestProfile(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PagedTestProfile DeserializePagedTestProfile(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(TestProfile.DeserializeTestProfile(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PagedTestProfile(value, nextLink, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureDeveloperLoadTestingContext.Default); + default: + throw new FormatException($"The model {nameof(PagedTestProfile)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + PagedTestProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PagedTestProfile PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePagedTestProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PagedTestProfile)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator PagedTestProfile(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePagedTestProfile(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestProfile.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestProfile.cs new file mode 100644 index 000000000000..9a3441c1d525 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestProfile.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.Developer.LoadTesting +{ + /// Paged collection of TestProfile items. + internal partial class PagedTestProfile + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The TestProfile items on this page. + internal PagedTestProfile(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The TestProfile items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal PagedTestProfile(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The TestProfile items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestProfileRun.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestProfileRun.Serialization.cs new file mode 100644 index 000000000000..e0cfb55b8d43 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestProfileRun.Serialization.cs @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; + +namespace Azure.Developer.LoadTesting +{ + /// Paged collection of TestProfileRun items. + internal partial class PagedTestProfileRun : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PagedTestProfileRun() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + 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) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedTestProfileRun)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (TestProfileRun item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + PagedTestProfileRun IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PagedTestProfileRun JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedTestProfileRun)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePagedTestProfileRun(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PagedTestProfileRun DeserializePagedTestProfileRun(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(TestProfileRun.DeserializeTestProfileRun(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PagedTestProfileRun(value, nextLink, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureDeveloperLoadTestingContext.Default); + default: + throw new FormatException($"The model {nameof(PagedTestProfileRun)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + PagedTestProfileRun IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PagedTestProfileRun PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePagedTestProfileRun(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PagedTestProfileRun)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator PagedTestProfileRun(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePagedTestProfileRun(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestProfileRun.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestProfileRun.cs new file mode 100644 index 000000000000..6340add2764a --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestProfileRun.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.Developer.LoadTesting +{ + /// Paged collection of TestProfileRun items. + internal partial class PagedTestProfileRun + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The TestProfileRun items on this page. + internal PagedTestProfileRun(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The TestProfileRun items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal PagedTestProfileRun(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The TestProfileRun items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestRun.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestRun.Serialization.cs new file mode 100644 index 000000000000..b1a06a9e8d59 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestRun.Serialization.cs @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; + +namespace Azure.Developer.LoadTesting +{ + /// Paged collection of TestRun items. + internal partial class PagedTestRun : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PagedTestRun() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + 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) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedTestRun)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (LoadTestRun item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + PagedTestRun IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PagedTestRun JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedTestRun)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePagedTestRun(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PagedTestRun DeserializePagedTestRun(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(LoadTestRun.DeserializeLoadTestRun(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PagedTestRun(value, nextLink, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureDeveloperLoadTestingContext.Default); + default: + throw new FormatException($"The model {nameof(PagedTestRun)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + PagedTestRun IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PagedTestRun PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePagedTestRun(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PagedTestRun)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator PagedTestRun(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePagedTestRun(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestRun.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestRun.cs new file mode 100644 index 000000000000..d6960e7ab472 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTestRun.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.Developer.LoadTesting +{ + /// Paged collection of TestRun items. + internal partial class PagedTestRun + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The TestRun items on this page. + internal PagedTestRun(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The TestRun items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal PagedTestRun(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The TestRun items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTrigger.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTrigger.Serialization.cs new file mode 100644 index 000000000000..8f71bef87a92 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTrigger.Serialization.cs @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; + +namespace Azure.Developer.LoadTesting +{ + /// Paged collection of Trigger items. + internal partial class PagedTrigger : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PagedTrigger() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + 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) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedTrigger)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (LoadTestingTrigger item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + PagedTrigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PagedTrigger JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedTrigger)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePagedTrigger(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PagedTrigger DeserializePagedTrigger(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(LoadTestingTrigger.DeserializeLoadTestingTrigger(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PagedTrigger(value, nextLink, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureDeveloperLoadTestingContext.Default); + default: + throw new FormatException($"The model {nameof(PagedTrigger)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + PagedTrigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PagedTrigger PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePagedTrigger(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PagedTrigger)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator PagedTrigger(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePagedTrigger(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTrigger.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTrigger.cs new file mode 100644 index 000000000000..a96170571951 --- /dev/null +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PagedTrigger.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.Developer.LoadTesting +{ + /// Paged collection of Trigger items. + internal partial class PagedTrigger + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The Trigger items on this page. + internal PagedTrigger(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The Trigger items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal PagedTrigger(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The Trigger items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailAction.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailAction.cs index 15672f674687..95d911674e31 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailAction.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailAction.cs @@ -14,38 +14,57 @@ namespace Azure.Developer.LoadTesting public readonly partial struct PassFailAction : IEquatable { private readonly string _value; + /// Test will continue to run even if pass fail metric criteria metric gets failed. + private const string ContinueValue = "continue"; + /// Test run will stop if pass fail criteria metric is not passed. + private const string StopValue = "stop"; /// Initializes a new instance of . + /// The value. /// is null. public PassFailAction(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string ContinueValue = "continue"; - private const string StopValue = "stop"; + _value = value; + } /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(PassFailAction left, PassFailAction right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(PassFailAction left, PassFailAction right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator PassFailAction(string value) => new PassFailAction(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator PassFailAction?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailAggregationFunction.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailAggregationFunction.cs index bec34915adcb..a8f0aebd6491 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailAggregationFunction.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailAggregationFunction.cs @@ -14,77 +14,122 @@ namespace Azure.Developer.LoadTesting 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)); - } - + /// Criteria applies for count value. private const string CountValue = "count"; + /// Criteria applies for given percentage value. private const string PercentageValue = "percentage"; + /// Criteria applies for avg value. private const string AverageValue = "avg"; + /// Criteria applies for 50th percentile value. private const string Percentile50Value = "p50"; + /// Criteria applies for 75th percentile value. private const string Percentile75Value = "p75"; + /// Criteria applies for 90th percentile value. private const string Percentile90Value = "p90"; + /// Criteria applies for 95th percentile value. private const string Percentile95Value = "p95"; + /// Criteria applies for 96th percentile value. private const string Percentile96Value = "p96"; + /// Criteria applies for 97th percentile value. private const string Percentile97Value = "p97"; + /// Criteria applies for 98th percentile value. private const string Percentile98Value = "p98"; + /// Criteria applies for 99th percentile value. private const string Percentile99Value = "p99"; + /// Criteria applies for 99.9th percentile value. private const string Percentile999Value = "p99.9"; + /// Criteria applies for 99.99th percentile value. private const string Percentile9999Value = "p99.99"; + /// Criteria applies for minimum value. private const string MinimumValue = "min"; + /// Criteria applies for maximum value. private const string MaximumValue = "max"; + /// Initializes a new instance of . + /// The value. + /// is null. + public PassFailAggregationFunction(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(PassFailAggregationFunction left, PassFailAggregationFunction right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(PassFailAggregationFunction left, PassFailAggregationFunction right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator PassFailAggregationFunction(string value) => new PassFailAggregationFunction(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator PassFailAggregationFunction?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailCriteria.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailCriteria.Serialization.cs index c2ade703c597..714bcc0335d9 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailCriteria.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailCriteria.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Pass fail criteria for a test. + public partial class PassFailCriteria : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter /// 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; + string 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); @@ -56,15 +55,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WriteEndObject(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -73,73 +72,79 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - PassFailCriteria IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + PassFailCriteria IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PassFailCriteria JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PassFailCriteria DeserializePassFailCriteria(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("passFailMetrics"u8)) + if (prop.NameEquals("passFailMetrics"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, PassFailMetric.DeserializePassFailMetric(property0.Value, options)); + dictionary.Add(prop0.Name, PassFailMetric.DeserializePassFailMetric(prop0.Value, options)); } passFailMetrics = dictionary; continue; } - if (property.NameEquals("passFailServerMetrics"u8)) + if (prop.NameEquals("passFailServerMetrics"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, PassFailServerMetric.DeserializePassFailServerMetric(property0.Value, options)); + dictionary.Add(prop0.Name, PassFailServerMetric.DeserializePassFailServerMetric(prop0.Value, options)); } passFailServerMetrics = dictionary; continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new PassFailCriteria(passFailMetrics ?? new ChangeTrackingDictionary(), passFailServerMetrics ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + return new PassFailCriteria(passFailMetrics ?? new ChangeTrackingDictionary(), passFailServerMetrics ?? new ChangeTrackingDictionary(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -149,15 +154,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions op } } - PassFailCriteria IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + PassFailCriteria IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PassFailCriteria PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializePassFailCriteria(document.RootElement, options); } default: @@ -165,22 +175,7 @@ PassFailCriteria IPersistableModel.Create(BinaryData data, Mod } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailCriteria.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailCriteria.cs index f2dc32a480e5..25813456aa05 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailCriteria.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailCriteria.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public PassFailCriteria() @@ -55,16 +26,17 @@ public PassFailCriteria() /// 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) + /// Keeps track of any properties unknown to the library. + internal PassFailCriteria(IDictionary passFailMetrics, IDictionary passFailServerMetrics, IDictionary additionalBinaryDataProperties) { PassFailMetrics = passFailMetrics; PassFailServerMetrics = passFailServerMetrics; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailMetric.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailMetric.Serialization.cs index 6022078542b1..0365d558294f 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailMetric.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailMetric.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Pass fail metric. + public partial class PassFailMetric : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp /// 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; + string 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); @@ -74,15 +73,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("result"u8); writer.WriteStringValue(Result.Value.ToString()); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -91,22 +90,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - PassFailMetric IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + PassFailMetric IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PassFailMetric JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PassFailMetric DeserializePassFailMetric(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -119,80 +123,78 @@ internal static PassFailMetric DeserializePassFailMetric(JsonElement element, Mo PassFailAction? action = default; double? actualValue = default; PassFailResult? result = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("clientMetric"u8)) + if (prop.NameEquals("clientMetric"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - clientMetric = new PfMetrics(property.Value.GetString()); + clientMetric = new PfMetrics(prop.Value.GetString()); continue; } - if (property.NameEquals("aggregate"u8)) + if (prop.NameEquals("aggregate"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - aggregate = new PassFailAggregationFunction(property.Value.GetString()); + aggregate = new PassFailAggregationFunction(prop.Value.GetString()); continue; } - if (property.NameEquals("condition"u8)) + if (prop.NameEquals("condition"u8)) { - condition = property.Value.GetString(); + condition = prop.Value.GetString(); continue; } - if (property.NameEquals("requestName"u8)) + if (prop.NameEquals("requestName"u8)) { - requestName = property.Value.GetString(); + requestName = prop.Value.GetString(); continue; } - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - value = property.Value.GetDouble(); + value = prop.Value.GetDouble(); continue; } - if (property.NameEquals("action"u8)) + if (prop.NameEquals("action"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - action = new PassFailAction(property.Value.GetString()); + action = new PassFailAction(prop.Value.GetString()); continue; } - if (property.NameEquals("actualValue"u8)) + if (prop.NameEquals("actualValue"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - actualValue = property.Value.GetDouble(); + actualValue = prop.Value.GetDouble(); continue; } - if (property.NameEquals("result"u8)) + if (prop.NameEquals("result"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - result = new PassFailResult(property.Value.GetString()); + result = new PassFailResult(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new PassFailMetric( clientMetric, aggregate, @@ -202,13 +204,16 @@ internal static PassFailMetric DeserializePassFailMetric(JsonElement element, Mo action, actualValue, result, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -218,15 +223,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opti } } - PassFailMetric IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + PassFailMetric IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PassFailMetric PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializePassFailMetric(document.RootElement, options); } default: @@ -234,22 +244,7 @@ PassFailMetric IPersistableModel.Create(BinaryData data, ModelRe } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailMetric.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailMetric.cs index 623cd825a9d1..77bf2f5409d1 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailMetric.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailMetric.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public PassFailMetric() @@ -58,8 +29,8 @@ public PassFailMetric() /// ‘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 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. @@ -67,8 +38,8 @@ public PassFailMetric() /// 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) + /// 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 additionalBinaryDataProperties) { ClientMetric = clientMetric; Aggregate = aggregate; @@ -78,11 +49,12 @@ internal PassFailMetric(PfMetrics? clientMetric, PassFailAggregationFunction? ag Action = action; ActualValue = actualValue; Result = result; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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’, @@ -90,19 +62,25 @@ internal PassFailMetric(PfMetrics? clientMetric, PassFailAggregationFunction? ag /// ‘count’ - for requests /// public PassFailAggregationFunction? Aggregate { get; set; } - /// The comparison operator. Supported types ‘>’, ‘<’. + + /// The comparison operator. Supported types ‘>’, ‘<’ . public string Condition { get; set; } - /// Request name for which the Pass fail criteria has to be applied. + + /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailResult.cs index 322a04ecded0..53216cf0f324 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailResult.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailResult.cs @@ -14,41 +14,62 @@ namespace Azure.Developer.LoadTesting public readonly partial struct PassFailResult : IEquatable { private readonly string _value; + /// Given pass fail criteria metric has passed. + private const string PassedValue = "passed"; + /// Given pass fail criteria metric couldn't determine. + private const string UndeterminedValue = "undetermined"; + /// Given pass fail criteria metric has failed. + private const string FailedValue = "failed"; /// Initializes a new instance of . + /// The value. /// is null. public PassFailResult(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string PassedValue = "passed"; - private const string UndeterminedValue = "undetermined"; - private const string FailedValue = "failed"; + _value = value; + } /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(PassFailResult left, PassFailResult right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(PassFailResult left, PassFailResult right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator PassFailResult(string value) => new PassFailResult(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator PassFailResult?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailServerMetric.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailServerMetric.Serialization.cs index a0e759d4e90c..87bc4ba95b08 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailServerMetric.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailServerMetric.Serialization.cs @@ -13,10 +13,16 @@ namespace Azure.Developer.LoadTesting { - public partial class PassFailServerMetric : IUtf8JsonSerializable, IJsonModel + /// Pass fail server metric. + public partial class PassFailServerMetric : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal PassFailServerMetric() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +34,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr /// 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; + string 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); @@ -61,15 +66,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("result"u8); writer.WriteStringValue(Result.Value.ToString()); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -78,22 +83,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - PassFailServerMetric IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + PassFailServerMetric IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PassFailServerMetric JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PassFailServerMetric DeserializePassFailServerMetric(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -107,73 +117,71 @@ internal static PassFailServerMetric DeserializePassFailServerMetric(JsonElement PassFailAction? action = default; double? actualValue = default; PassFailResult? result = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("resourceId"u8)) + if (prop.NameEquals("resourceId"u8)) { - resourceId = new ResourceIdentifier(property.Value.GetString()); + resourceId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("metricNamespace"u8)) + if (prop.NameEquals("metricNamespace"u8)) { - metricNamespace = property.Value.GetString(); + metricNamespace = prop.Value.GetString(); continue; } - if (property.NameEquals("metricName"u8)) + if (prop.NameEquals("metricName"u8)) { - metricName = property.Value.GetString(); + metricName = prop.Value.GetString(); continue; } - if (property.NameEquals("aggregation"u8)) + if (prop.NameEquals("aggregation"u8)) { - aggregation = property.Value.GetString(); + aggregation = prop.Value.GetString(); continue; } - if (property.NameEquals("condition"u8)) + if (prop.NameEquals("condition"u8)) { - condition = property.Value.GetString(); + condition = prop.Value.GetString(); continue; } - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { - value = property.Value.GetDouble(); + value = prop.Value.GetDouble(); continue; } - if (property.NameEquals("action"u8)) + if (prop.NameEquals("action"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - action = new PassFailAction(property.Value.GetString()); + action = new PassFailAction(prop.Value.GetString()); continue; } - if (property.NameEquals("actualValue"u8)) + if (prop.NameEquals("actualValue"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - actualValue = property.Value.GetDouble(); + actualValue = prop.Value.GetDouble(); continue; } - if (property.NameEquals("result"u8)) + if (prop.NameEquals("result"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - result = new PassFailResult(property.Value.GetString()); + result = new PassFailResult(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new PassFailServerMetric( resourceId, metricNamespace, @@ -184,13 +192,16 @@ internal static PassFailServerMetric DeserializePassFailServerMetric(JsonElement action, actualValue, result, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -200,15 +211,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption } } - PassFailServerMetric IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + PassFailServerMetric IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PassFailServerMetric PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializePassFailServerMetric(document.RootElement, options); } default: @@ -216,22 +232,7 @@ PassFailServerMetric IPersistableModel.Create(BinaryData d } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailServerMetric.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailServerMetric.cs index e595efde037e..64e2811756c6 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailServerMetric.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailServerMetric.cs @@ -14,44 +14,15 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// 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 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) @@ -75,13 +46,13 @@ public PassFailServerMetric(ResourceIdentifier resourceId, string metricNamespac /// The server metric namespace. /// The server metric name. /// Aggregation Type. - /// The comparison operator. Supported types ‘>’, ‘<’. + /// 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. + /// 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) + /// 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 additionalBinaryDataProperties) { ResourceId = resourceId; MetricNamespace = metricNamespace; @@ -92,30 +63,33 @@ internal PassFailServerMetric(ResourceIdentifier resourceId, string metricNamesp Action = action; ActualValue = actualValue; Result = result; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal PassFailServerMetric() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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 ‘>’, ‘<’. + + /// 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. + + /// The actual value of the server metric . public double? ActualValue { get; } + /// Outcome of the test run. public PassFailResult? Result { get; } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailTestResult.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailTestResult.cs index 9e9ba8dcff58..d5fc74856740 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailTestResult.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PassFailTestResult.cs @@ -14,41 +14,62 @@ namespace Azure.Developer.LoadTesting public readonly partial struct PassFailTestResult : IEquatable { private readonly string _value; + /// Pass/fail criteria has passed. + private const string PASSEDValue = "PASSED"; + /// Pass/fail criteria is not applicable. + private const string NOTAPPLICABLEValue = "NOT_APPLICABLE"; + /// Pass/fail criteria has failed. + private const string FAILEDValue = "FAILED"; /// Initializes a new instance of . + /// The value. /// is null. public PassFailTestResult(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string PASSEDValue = "PASSED"; - private const string NOTAPPLICABLEValue = "NOT_APPLICABLE"; - private const string FAILEDValue = "FAILED"; + _value = value; + } /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(PassFailTestResult left, PassFailTestResult right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(PassFailTestResult left, PassFailTestResult right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator PassFailTestResult(string value) => new PassFailTestResult(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator PassFailTestResult?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PfMetrics.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PfMetrics.cs index cd959571727a..7d24934ea40f 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PfMetrics.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/PfMetrics.cs @@ -14,47 +14,72 @@ namespace Azure.Developer.LoadTesting public readonly partial struct PfMetrics : IEquatable { private readonly string _value; + /// Pass fail criteria for response time metric in milliseconds. + private const string ResponseTimeInMillisecondsValue = "response_time_ms"; + /// Pass fail criteria for latency metric in milliseconds. + private const string LatencyValue = "latency"; + /// Pass fail criteria for error metric. + private const string ErrorValue = "error"; + /// Pass fail criteria for total requests. + private const string RequestsValue = "requests"; + /// Pass fail criteria for request per second. + private const string RequestsPerSecondValue = "requests_per_sec"; /// Initializes a new instance of . + /// The value. /// is null. public PfMetrics(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, 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"; + _value = value; + } /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(PfMetrics left, PfMetrics right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(PfMetrics left, PfMetrics right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator PfMetrics(string value) => new PfMetrics(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator PfMetrics?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecommendationCategory.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecommendationCategory.cs index 588b050d7070..973a4e06d79c 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecommendationCategory.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecommendationCategory.cs @@ -14,38 +14,57 @@ namespace Azure.Developer.LoadTesting public readonly partial struct RecommendationCategory : IEquatable { private readonly string _value; + /// The recommendation for this category optimizes the throughput/RPS (Requests per Second) of the app. + private const string ThroughputOptimizedValue = "ThroughputOptimized"; + /// The recommendation for this category optimizes the cost of the app. + private const string CostOptimizedValue = "CostOptimized"; /// Initializes a new instance of . + /// The value. /// is null. public RecommendationCategory(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string ThroughputOptimizedValue = "ThroughputOptimized"; - private const string CostOptimizedValue = "CostOptimized"; + _value = value; + } /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(RecommendationCategory left, RecommendationCategory right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(RecommendationCategory left, RecommendationCategory right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator RecommendationCategory(string value) => new RecommendationCategory(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator RecommendationCategory?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceEnd.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceEnd.Serialization.cs index c7b0d8f659e6..5a8f6127223f 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceEnd.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceEnd.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// 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 : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt /// 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; + string 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); @@ -44,15 +43,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("endDateTime"u8); writer.WriteStringValue(EndDateTime.Value, "O"); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,63 +60,69 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - RecurrenceEnd IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + RecurrenceEnd IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual RecurrenceEnd JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RecurrenceEnd DeserializeRecurrenceEnd(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("numberOfOccurrences"u8)) + if (prop.NameEquals("numberOfOccurrences"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - numberOfOccurrences = property.Value.GetInt32(); + numberOfOccurrences = prop.Value.GetInt32(); continue; } - if (property.NameEquals("endDateTime"u8)) + if (prop.NameEquals("endDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - endDateTime = property.Value.GetDateTimeOffset("O"); + endDateTime = prop.Value.GetDateTimeOffset("O"); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new RecurrenceEnd(numberOfOccurrences, endDateTime, serializedAdditionalRawData); + return new RecurrenceEnd(numberOfOccurrences, endDateTime, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -127,15 +132,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions optio } } - RecurrenceEnd IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + RecurrenceEnd IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RecurrenceEnd PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeRecurrenceEnd(document.RootElement, options); } default: @@ -143,22 +153,7 @@ RecurrenceEnd IPersistableModel.Create(BinaryData data, ModelRead } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceEnd.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceEnd.cs index a0761463bdff..b8d1ce6c63a0 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceEnd.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceEnd.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public RecurrenceEnd() @@ -53,16 +24,17 @@ 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) + /// Keeps track of any properties unknown to the library. + internal RecurrenceEnd(int? numberOfOccurrences, DateTimeOffset? endDateTime, IDictionary additionalBinaryDataProperties) { NumberOfOccurrences = numberOfOccurrences; EndDateTime = endDateTime; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceStatus.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceStatus.Serialization.cs index f8b625571c0f..c91dc1ca19de 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceStatus.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceStatus.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Actual state of the recurrence for the trigger. + public partial class RecurrenceStatus : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter /// 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; + string 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); @@ -43,21 +42,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("nextScheduledDateTimes"u8); writer.WriteStartArray(); - foreach (var item in NextScheduledDateTimes) + foreach (DateTimeOffset item in NextScheduledDateTimes) { writer.WriteStringValue(item, "O"); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -66,49 +65,53 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - RecurrenceStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + RecurrenceStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual RecurrenceStatus JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RecurrenceStatus DeserializeRecurrenceStatus(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IList nextScheduledDateTimes = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("remainingOccurrences"u8)) + if (prop.NameEquals("remainingOccurrences"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - remainingOccurrences = property.Value.GetInt32(); + remainingOccurrences = prop.Value.GetInt32(); continue; } - if (property.NameEquals("nextScheduledDateTimes"u8)) + if (prop.NameEquals("nextScheduledDateTimes"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(item.GetDateTimeOffset("O")); } @@ -117,17 +120,19 @@ internal static RecurrenceStatus DeserializeRecurrenceStatus(JsonElement element } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new RecurrenceStatus(remainingOccurrences, nextScheduledDateTimes ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new RecurrenceStatus(remainingOccurrences, nextScheduledDateTimes ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -137,15 +142,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions op } } - RecurrenceStatus IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + RecurrenceStatus IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RecurrenceStatus PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeRecurrenceStatus(document.RootElement, options); } default: @@ -153,22 +163,7 @@ RecurrenceStatus IPersistableModel.Create(BinaryData data, Mod } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceStatus.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceStatus.cs index 19acfb9c7750..a04283a3cef7 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceStatus.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceStatus.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal RecurrenceStatus() @@ -54,17 +25,18 @@ internal RecurrenceStatus() /// 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) + /// Keeps track of any properties unknown to the library. + internal RecurrenceStatus(int? remainingOccurrences, IList nextScheduledDateTimes, IDictionary additionalBinaryDataProperties) { RemainingOccurrences = remainingOccurrences; NextScheduledDateTimes = nextScheduledDateTimes; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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; } + public IList NextScheduledDateTimes { get; } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceWithCron.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceWithCron.Serialization.cs index 9142b9b552c9..664f314e4f78 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceWithCron.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceWithCron.Serialization.cs @@ -9,14 +9,19 @@ 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 + /// Recurrence is set based on cron expression. + public partial class RecurrenceWithCron : LoadTestingRecurrence, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal RecurrenceWithCron() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,76 +33,81 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit /// 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; + string 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) + /// The JSON reader. + /// The client options for reading and writing models. + RecurrenceWithCron IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (RecurrenceWithCron)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override LoadTestingRecurrence JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RecurrenceWithCron DeserializeRecurrenceWithCron(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string cronExpression = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("cronExpression"u8)) + if (prop.NameEquals("frequency"u8)) { - cronExpression = property.Value.GetString(); + frequency = new Frequency(prop.Value.GetString()); continue; } - if (property.NameEquals("frequency"u8)) + if (prop.NameEquals("recurrenceEnd"u8)) { - frequency = new Frequency(property.Value.GetString()); - continue; - } - if (property.NameEquals("recurrenceEnd"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(property.Value, options); + recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(prop.Value, options); + continue; + } + if (prop.NameEquals("cronExpression"u8)) + { + cronExpression = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new RecurrenceWithCron(frequency, recurrenceEnd, serializedAdditionalRawData, cronExpression); + return new RecurrenceWithCron(frequency, recurrenceEnd, additionalBinaryDataProperties, cronExpression); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -107,15 +117,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - RecurrenceWithCron IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + RecurrenceWithCron IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (RecurrenceWithCron)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override LoadTestingRecurrence PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeRecurrenceWithCron(document.RootElement, options); } default: @@ -123,22 +138,7 @@ RecurrenceWithCron IPersistableModel.Create(BinaryData data, } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceWithCron.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceWithCron.cs index f36f69f80f4f..f07f9ac9f488 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceWithCron.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RecurrenceWithCron.cs @@ -16,29 +16,23 @@ public partial class RecurrenceWithCron : LoadTestingRecurrence /// Initializes a new instance of . /// Cron expression for the recurrence. /// is null. - public RecurrenceWithCron(string cronExpression) + public RecurrenceWithCron(string cronExpression) : base(Frequency.Cron) { 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. + /// 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) + internal RecurrenceWithCron(Frequency frequency, RecurrenceEnd recurrenceEnd, IDictionary additionalBinaryDataProperties, string cronExpression) : base(frequency, recurrenceEnd, additionalBinaryDataProperties) { 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RegionalConfiguration.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RegionalConfiguration.Serialization.cs index 382b54dfc895..486389bb8a22 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RegionalConfiguration.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RegionalConfiguration.Serialization.cs @@ -13,10 +13,16 @@ namespace Azure.Developer.LoadTesting { - public partial class RegionalConfiguration : IUtf8JsonSerializable, IJsonModel + /// Region distribution configuration for the load test. + public partial class RegionalConfiguration : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal RegionalConfiguration() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,25 +34,24 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW /// 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; + string 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) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -55,55 +60,61 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - RegionalConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + RegionalConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual RegionalConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RegionalConfiguration DeserializeRegionalConfiguration(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("engineInstances"u8)) + if (prop.NameEquals("engineInstances"u8)) { - engineInstances = property.Value.GetInt32(); + engineInstances = prop.Value.GetInt32(); continue; } - if (property.NameEquals("region"u8)) + if (prop.NameEquals("region"u8)) { - region = new AzureLocation(property.Value.GetString()); + region = new AzureLocation(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new RegionalConfiguration(engineInstances, region, serializedAdditionalRawData); + return new RegionalConfiguration(engineInstances, region, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -113,15 +124,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - RegionalConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + RegionalConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RegionalConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeRegionalConfiguration(document.RootElement, options); } default: @@ -129,22 +145,7 @@ RegionalConfiguration IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RegionalConfiguration.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RegionalConfiguration.cs index fd742c09e86f..06e87da1d490 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RegionalConfiguration.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RegionalConfiguration.cs @@ -14,40 +14,11 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// 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. + /// 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". @@ -60,27 +31,23 @@ public RegionalConfiguration(int engineInstances, AzureLocation 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. + /// 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) + /// Keeps track of any properties unknown to the library. + internal RegionalConfiguration(int engineInstances, AzureLocation region, IDictionary additionalBinaryDataProperties) { EngineInstances = engineInstances; Region = region; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal RegionalConfiguration() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } - /// The number of engine instances to execute load test in specified region. Supported values are in range of 1-400. + /// 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". diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RequestDataLevel.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RequestDataLevel.cs index b55aa822172b..5b11a45deaaa 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RequestDataLevel.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/RequestDataLevel.cs @@ -14,38 +14,57 @@ namespace Azure.Developer.LoadTesting public readonly partial struct RequestDataLevel : IEquatable { private readonly string _value; + /// No request data will be collected. + private const string NONEValue = "NONE"; + /// Request data will be collected in case of failed requests. + private const string ERRORSValue = "ERRORS"; /// Initializes a new instance of . + /// The value. /// is null. public RequestDataLevel(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string NONEValue = "NONE"; - private const string ERRORSValue = "ERRORS"; + _value = value; + } /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(RequestDataLevel left, RequestDataLevel right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(RequestDataLevel left, RequestDataLevel right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator RequestDataLevel(string value) => new RequestDataLevel(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator RequestDataLevel?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ResourceKind.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ResourceKind.cs index 10af6895b2ec..5ec5f5d67433 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ResourceKind.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ResourceKind.cs @@ -14,35 +14,52 @@ namespace Azure.Developer.LoadTesting internal readonly partial struct ResourceKind : IEquatable { private readonly string _value; + /// Resource is a Azure FunctionApp on Flex Consumption Plan. + private const string FunctionsFlexConsumptionValue = "FunctionsFlexConsumption"; /// Initializes a new instance of . + /// The value. /// is null. public ResourceKind(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string FunctionsFlexConsumptionValue = "FunctionsFlexConsumption"; + _value = value; + } /// Resource is a Azure FunctionApp on Flex Consumption Plan. public static ResourceKind FunctionsFlexConsumption { get; } = new ResourceKind(FunctionsFlexConsumptionValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(ResourceKind left, ResourceKind right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(ResourceKind left, ResourceKind right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator ResourceKind(string value) => new ResourceKind(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator ResourceKind?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ResourceMetric.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ResourceMetric.Serialization.cs index 2f61689941fe..519e394bc022 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ResourceMetric.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ResourceMetric.Serialization.cs @@ -13,10 +13,20 @@ namespace Azure.Developer.LoadTesting { - public partial class ResourceMetric : IUtf8JsonSerializable, IJsonModel + /// + /// 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 : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal ResourceMetric() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +38,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp /// 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; + string 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); @@ -59,15 +68,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName("resourceType"u8); writer.WriteStringValue(ResourceType); - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -76,22 +85,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ResourceMetric IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ResourceMetric IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceMetric JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ResourceMetric DeserializeResourceMetric(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -104,56 +118,54 @@ internal static ResourceMetric DeserializeResourceMetric(JsonElement element, Mo string aggregation = default; string unit = default; string resourceType = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - id = property.Value.GetString(); + id = prop.Value.GetString(); continue; } - if (property.NameEquals("resourceId"u8)) + if (prop.NameEquals("resourceId"u8)) { - resourceId = new ResourceIdentifier(property.Value.GetString()); + resourceId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("metricNamespace"u8)) + if (prop.NameEquals("metricNamespace"u8)) { - metricNamespace = property.Value.GetString(); + metricNamespace = prop.Value.GetString(); continue; } - if (property.NameEquals("displayDescription"u8)) + if (prop.NameEquals("displayDescription"u8)) { - displayDescription = property.Value.GetString(); + displayDescription = prop.Value.GetString(); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("aggregation"u8)) + if (prop.NameEquals("aggregation"u8)) { - aggregation = property.Value.GetString(); + aggregation = prop.Value.GetString(); continue; } - if (property.NameEquals("unit"u8)) + if (prop.NameEquals("unit"u8)) { - unit = property.Value.GetString(); + unit = prop.Value.GetString(); continue; } - if (property.NameEquals("resourceType"u8)) + if (prop.NameEquals("resourceType"u8)) { - resourceType = property.Value.GetString(); + resourceType = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new ResourceMetric( id, resourceId, @@ -163,13 +175,16 @@ internal static ResourceMetric DeserializeResourceMetric(JsonElement element, Mo aggregation, unit, resourceType, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -179,15 +194,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opti } } - ResourceMetric IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + ResourceMetric IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceMetric PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeResourceMetric(document.RootElement, options); } default: @@ -195,22 +215,7 @@ ResourceMetric IPersistableModel.Create(BinaryData data, ModelRe } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ResourceMetric.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ResourceMetric.cs index 5059dad8af80..1948104f5888 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ResourceMetric.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ResourceMetric.cs @@ -18,37 +18,8 @@ namespace Azure.Developer.LoadTesting /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// Azure resource id. @@ -81,8 +52,8 @@ public ResourceMetric(ResourceIdentifier resourceId, string metricNamespace, str /// 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) + /// 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 additionalBinaryDataProperties) { Id = id; ResourceId = resourceId; @@ -92,28 +63,30 @@ internal ResourceMetric(string id, ResourceIdentifier resourceId, string metricN Aggregation = aggregation; Unit = unit; ResourceType = resourceType; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ResourceMetric() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ScheduleTestsTrigger.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ScheduleTestsTrigger.Serialization.cs index aa241da20bc3..e25a8f7815a0 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ScheduleTestsTrigger.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ScheduleTestsTrigger.Serialization.cs @@ -9,14 +9,19 @@ 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 + /// ScheduleTestsTrigger model. + public partial class ScheduleTestsTrigger : LoadTestingTrigger, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal ScheduleTestsTrigger() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,17 +33,21 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr /// 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; + string 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) + foreach (string item in TestIds) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); @@ -59,30 +68,31 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - ScheduleTestsTrigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ScheduleTestsTrigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ScheduleTestsTrigger)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override LoadTestingTrigger JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ScheduleTestsTrigger DeserializeScheduleTestsTrigger(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IList testIds = default; - DateTimeOffset? startDateTime = default; - RecurrenceStatus recurrenceStatus = default; - LoadTestingRecurrence recurrence = default; string triggerId = default; string displayName = default; string description = default; @@ -93,119 +103,128 @@ internal static ScheduleTestsTrigger DeserializeScheduleTestsTrigger(JsonElement string createdBy = default; DateTimeOffset? lastModifiedDateTime = default; string lastModifiedBy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList testIds = default; + DateTimeOffset? startDateTime = default; + RecurrenceStatus recurrenceStatus = default; + LoadTestingRecurrence recurrence = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("testIds"u8)) + if (prop.NameEquals("triggerId"u8)) { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - testIds = array; + triggerId = prop.Value.GetString(); continue; } - if (property.NameEquals("startDateTime"u8)) + if (prop.NameEquals("displayName"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - startDateTime = property.Value.GetDateTimeOffset("O"); + displayName = prop.Value.GetString(); continue; } - if (property.NameEquals("recurrenceStatus"u8)) + if (prop.NameEquals("description"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("kind"u8)) + { + kind = new TriggerType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("state"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - recurrenceStatus = RecurrenceStatus.DeserializeRecurrenceStatus(property.Value, options); + state = new TriggerState(prop.Value.GetString()); continue; } - if (property.NameEquals("recurrence"u8)) + if (prop.NameEquals("stateDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - recurrence = LoadTestingRecurrence.DeserializeLoadTestingRecurrence(property.Value, options); + stateDetails = StateDetails.DeserializeStateDetails(prop.Value, options); continue; } - if (property.NameEquals("triggerId"u8)) + if (prop.NameEquals("createdDateTime"u8)) { - triggerId = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("displayName"u8)) + if (prop.NameEquals("createdBy"u8)) { - displayName = property.Value.GetString(); + createdBy = prop.Value.GetString(); continue; } - if (property.NameEquals("description"u8)) + if (prop.NameEquals("lastModifiedDateTime"u8)) { - description = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("kind"u8)) + if (prop.NameEquals("lastModifiedBy"u8)) { - kind = new TriggerType(property.Value.GetString()); + lastModifiedBy = prop.Value.GetString(); continue; } - if (property.NameEquals("state"u8)) + if (prop.NameEquals("testIds"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) { - continue; + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } } - state = new TriggerState(property.Value.GetString()); + testIds = array; continue; } - if (property.NameEquals("stateDetails"u8)) + if (prop.NameEquals("startDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - stateDetails = StateDetails.DeserializeStateDetails(property.Value, options); + startDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("createdDateTime"u8)) + if (prop.NameEquals("recurrenceStatus"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - createdDateTime = property.Value.GetDateTimeOffset("O"); - continue; - } - if (property.NameEquals("createdBy"u8)) - { - createdBy = property.Value.GetString(); + recurrenceStatus = RecurrenceStatus.DeserializeRecurrenceStatus(prop.Value, options); continue; } - if (property.NameEquals("lastModifiedDateTime"u8)) + if (prop.NameEquals("recurrence"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); - continue; - } - if (property.NameEquals("lastModifiedBy"u8)) - { - lastModifiedBy = property.Value.GetString(); + recurrence = LoadTestingRecurrence.DeserializeLoadTestingRecurrence(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new ScheduleTestsTrigger( triggerId, displayName, @@ -217,17 +236,20 @@ internal static ScheduleTestsTrigger DeserializeScheduleTestsTrigger(JsonElement createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData, + additionalBinaryDataProperties, testIds, startDateTime, recurrenceStatus, recurrence); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -237,15 +259,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption } } - ScheduleTestsTrigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + ScheduleTestsTrigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ScheduleTestsTrigger)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override LoadTestingTrigger PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeScheduleTestsTrigger(document.RootElement, options); } default: @@ -253,22 +280,7 @@ ScheduleTestsTrigger IPersistableModel.Create(BinaryData d } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ScheduleTestsTrigger.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ScheduleTestsTrigger.cs index c90902a17b49..8dae6ce5920b 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ScheduleTestsTrigger.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/ScheduleTestsTrigger.cs @@ -18,12 +18,11 @@ public partial class ScheduleTestsTrigger : LoadTestingTrigger /// 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) + public ScheduleTestsTrigger(string displayName, IEnumerable testIds) : base(displayName, TriggerType.ScheduleTestsTrigger) { Argument.AssertNotNull(displayName, nameof(displayName)); Argument.AssertNotNull(testIds, nameof(testIds)); - Kind = TriggerType.ScheduleTestsTrigger; TestIds = testIds.ToList(); } @@ -38,16 +37,12 @@ public ScheduleTestsTrigger(string displayName, IEnumerable testIds) : b /// 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. + /// 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, LoadTestingRecurrence recurrence) : base(triggerId, displayName, description, kind, state, stateDetails, createdDateTime, createdBy, lastModifiedDateTime, lastModifiedBy, serializedAdditionalRawData) + /// Recurrence details of the trigger. Null if schedule is not recurring. + internal ScheduleTestsTrigger(string triggerId, string displayName, string description, TriggerType kind, TriggerState? state, StateDetails stateDetails, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary additionalBinaryDataProperties, IList testIds, DateTimeOffset? startDateTime, RecurrenceStatus recurrenceStatus, LoadTestingRecurrence recurrence) : base(triggerId, displayName, description, kind, state, stateDetails, createdDateTime, createdBy, lastModifiedDateTime, lastModifiedBy, additionalBinaryDataProperties) { TestIds = testIds; StartDateTime = startDateTime; @@ -55,22 +50,16 @@ internal ScheduleTestsTrigger(string triggerId, string displayName, string descr 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. + + /// Gets the RecurrenceStatus. 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 . - /// + + /// Recurrence details of the trigger. Null if schedule is not recurring. public LoadTestingRecurrence Recurrence { get; set; } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/SecretType.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/SecretType.cs index 6937c671909b..ea5a3596e9c9 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/SecretType.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/SecretType.cs @@ -14,38 +14,57 @@ namespace Azure.Developer.LoadTesting public readonly partial struct SecretType : IEquatable { private readonly string _value; + /// If the secret is stored in an Azure Key Vault. + private const string KeyVaultSecretUriValue = "AKV_SECRET_URI"; + /// If the secret value provided as plain text. + private const string SecretValueValue = "SECRET_VALUE"; /// Initializes a new instance of . + /// The value. /// is null. public SecretType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string KeyVaultSecretUriValue = "AKV_SECRET_URI"; - private const string SecretValueValue = "SECRET_VALUE"; + _value = 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(SecretType left, SecretType right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(SecretType left, SecretType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator SecretType(string value) => new SecretType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator SecretType?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/StateDetails.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/StateDetails.Serialization.cs index d6520980453e..f2bab6a3c42a 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/StateDetails.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/StateDetails.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// State details of the trigger. + public partial class StateDetails : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,26 +28,25 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti /// 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; + string 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) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -56,49 +55,55 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - StateDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + StateDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual StateDetails JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static StateDetails DeserializeStateDetails(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("message"u8)) + if (prop.NameEquals("message"u8)) { - message = property.Value.GetString(); + message = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new StateDetails(message, serializedAdditionalRawData); + return new StateDetails(message, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -108,15 +113,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions option } } - StateDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + StateDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual StateDetails PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeStateDetails(document.RootElement, options); } default: @@ -124,22 +134,7 @@ StateDetails IPersistableModel.Create(BinaryData data, ModelReader } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/StateDetails.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/StateDetails.cs index fa8f6c783e0b..e21a993eb5ff 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/StateDetails.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/StateDetails.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal StateDetails() @@ -52,11 +23,11 @@ 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) + /// Keeps track of any properties unknown to the library. + internal StateDetails(string message, IDictionary additionalBinaryDataProperties) { Message = message; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The error message if the trigger is in disabled state. diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TargetResourceConfigurations.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TargetResourceConfigurations.Serialization.cs index 5e319fe3e062..0c00e0f6a108 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TargetResourceConfigurations.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TargetResourceConfigurations.Serialization.cs @@ -8,15 +8,23 @@ using System; using System.ClientModel.Primitives; using System.Text.Json; -using Azure.Core; namespace Azure.Developer.LoadTesting { + /// + /// Configurations of a target resource. This varies with the kind of resource. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// [PersistableModelProxy(typeof(UnknownTargetResourceConfigurations))] - public partial class TargetResourceConfigurations : IUtf8JsonSerializable, IJsonModel + public abstract partial class TargetResourceConfigurations : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TargetResourceConfigurations() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,23 +36,22 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model /// 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; + string 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) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -53,40 +60,49 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TargetResourceConfigurations IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TargetResourceConfigurations IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TargetResourceConfigurations JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TargetResourceConfigurations DeserializeTargetResourceConfigurations(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - if (element.TryGetProperty("kind", out JsonElement discriminator)) + if (element.TryGetProperty("kind"u8, out JsonElement discriminator)) { switch (discriminator.GetString()) { - case "FunctionsFlexConsumption": return FunctionFlexConsumptionTargetResourceConfigurations.DeserializeFunctionFlexConsumptionTargetResourceConfigurations(element, options); + 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; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -96,15 +112,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - TargetResourceConfigurations IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TargetResourceConfigurations IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TargetResourceConfigurations PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTargetResourceConfigurations(document.RootElement, options); } default: @@ -112,22 +133,7 @@ TargetResourceConfigurations IPersistableModel.Cre } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TargetResourceConfigurations.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TargetResourceConfigurations.cs index 653c885e35ba..d8e22dca8f47 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TargetResourceConfigurations.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TargetResourceConfigurations.cs @@ -12,55 +12,27 @@ 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 . + /// Please note this is the abstract base class. The derived classes available for instantiation are: . /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . - protected TargetResourceConfigurations() + /// Kind of the resource for which the configurations apply. + private protected TargetResourceConfigurations(ResourceKind kind) { + Kind = kind; } /// 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) + /// Keeps track of any properties unknown to the library. + internal TargetResourceConfigurations(ResourceKind kind, IDictionary additionalBinaryDataProperties) { Kind = kind; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Kind of the resource for which the configurations apply. diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestAppComponents.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestAppComponents.Serialization.cs index 032f0deb6b8d..7cc4a83afa70 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestAppComponents.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestAppComponents.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; namespace Azure.Developer.LoadTesting { - public partial class TestAppComponents : IUtf8JsonSerializable, IJsonModel + /// Test app components. + public partial class TestAppComponents : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TestAppComponents() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +34,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite /// 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; + string 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) @@ -67,15 +72,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("lastModifiedBy"u8); writer.WriteStringValue(LastModifiedBy); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -84,22 +89,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestAppComponents IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestAppComponents IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestAppComponents JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestAppComponents DeserializeTestAppComponents(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -110,59 +120,57 @@ internal static TestAppComponents DeserializeTestAppComponents(JsonElement eleme string createdBy = default; DateTimeOffset? lastModifiedDateTime = default; string lastModifiedBy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("components"u8)) + if (prop.NameEquals("components"u8)) { Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, LoadTestingAppComponent.DeserializeLoadTestingAppComponent(property0.Value, options)); + dictionary.Add(prop0.Name, LoadTestingAppComponent.DeserializeLoadTestingAppComponent(prop0.Value, options)); } components = dictionary; continue; } - if (property.NameEquals("testId"u8)) + if (prop.NameEquals("testId"u8)) { - testId = property.Value.GetString(); + testId = prop.Value.GetString(); continue; } - if (property.NameEquals("createdDateTime"u8)) + if (prop.NameEquals("createdDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - createdDateTime = property.Value.GetDateTimeOffset("O"); + createdDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("createdBy"u8)) + if (prop.NameEquals("createdBy"u8)) { - createdBy = property.Value.GetString(); + createdBy = prop.Value.GetString(); continue; } - if (property.NameEquals("lastModifiedDateTime"u8)) + if (prop.NameEquals("lastModifiedDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + lastModifiedDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("lastModifiedBy"u8)) + if (prop.NameEquals("lastModifiedBy"u8)) { - lastModifiedBy = property.Value.GetString(); + lastModifiedBy = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new TestAppComponents( components, testId, @@ -170,13 +178,16 @@ internal static TestAppComponents DeserializeTestAppComponents(JsonElement eleme createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -186,15 +197,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o } } - TestAppComponents IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestAppComponents IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestAppComponents PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestAppComponents(document.RootElement, options); } default: @@ -202,22 +218,14 @@ TestAppComponents IPersistableModel.Create(BinaryData data, M } } + /// The client options for reading and writing models. 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() + /// The to deserialize the from. + public static explicit operator TestAppComponents(Response response) { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); - return content; + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestAppComponents(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestAppComponents.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestAppComponents.cs index 3e7e8a90b428..9021ec18139a 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestAppComponents.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestAppComponents.cs @@ -13,43 +13,14 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// 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 } + /// : resource object } /// /// is null. public TestAppComponents(IDictionary components) @@ -63,15 +34,15 @@ public TestAppComponents(IDictionary components /// /// Azure resource collection { resource id (fully qualified resource Id e.g /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) - /// : resource object } + /// : 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) + /// Keeps track of any properties unknown to the library. + internal TestAppComponents(IDictionary components, string testId, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary additionalBinaryDataProperties) { Components = components; TestId = testId; @@ -79,28 +50,28 @@ internal TestAppComponents(IDictionary componen CreatedBy = createdBy; LastModifiedDateTime = lastModifiedDateTime; LastModifiedBy = lastModifiedBy; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal TestAppComponents() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// /// Azure resource collection { resource id (fully qualified resource Id e.g /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) - /// : resource object } + /// : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestCertificate.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestCertificate.Serialization.cs index 8a9b32b22129..2d9541e966b7 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestCertificate.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestCertificate.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Certificates metadata. + public partial class TestCertificate : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO /// 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; + string 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); @@ -49,15 +48,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -66,65 +65,71 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestCertificate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestCertificate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestCertificate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestCertificate DeserializeTestCertificate(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string value = default; - CertificateType? type = default; + CertificateType? certificateKind = default; string name = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { - value = property.Value.GetString(); + value = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - type = new CertificateType(property.Value.GetString()); + certificateKind = new CertificateType(prop.Value.GetString()); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TestCertificate(value, type, name, serializedAdditionalRawData); + return new TestCertificate(value, certificateKind, name, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -134,15 +139,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opt } } - TestCertificate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestCertificate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestCertificate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestCertificate(document.RootElement, options); } default: @@ -150,22 +160,7 @@ TestCertificate IPersistableModel.Create(BinaryData data, Model } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestCertificate.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestCertificate.cs index 52ba75d2b6ca..7c03fe7b1d9b 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestCertificate.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestCertificate.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public TestCertificate() @@ -54,19 +25,21 @@ public TestCertificate() /// 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) + /// Keeps track of any properties unknown to the library. + internal TestCertificate(string value, CertificateType? certificateKind, string name, IDictionary additionalBinaryDataProperties) { Value = value; CertificateKind = certificateKind; Name = name; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestFileInfo.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestFileInfo.Serialization.cs index 979eeac18042..2f785cbb5564 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestFileInfo.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestFileInfo.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; namespace Azure.Developer.LoadTesting { - public partial class TestFileInfo : IUtf8JsonSerializable, IJsonModel + /// Test file info. + public partial class TestFileInfo : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TestFileInfo() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +34,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti /// 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; + string 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)) @@ -61,15 +66,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("validationFailureDetails"u8); writer.WriteStringValue(ValidationFailureDetails); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -78,102 +83,108 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestFileInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestFileInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestFileInfo JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestFileInfo DeserializeTestFileInfo(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string fileName = default; - Uri url = default; + Uri uri = default; LoadTestingFileType? fileType = default; - DateTimeOffset? expireDateTime = default; + DateTimeOffset? expiresOn = default; FileValidationStatus? validationStatus = default; string validationFailureDetails = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("fileName"u8)) + if (prop.NameEquals("fileName"u8)) { - fileName = property.Value.GetString(); + fileName = prop.Value.GetString(); continue; } - if (property.NameEquals("url"u8)) + if (prop.NameEquals("url"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - url = new Uri(property.Value.GetString()); + uri = new Uri(prop.Value.GetString()); continue; } - if (property.NameEquals("fileType"u8)) + if (prop.NameEquals("fileType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - fileType = new LoadTestingFileType(property.Value.GetString()); + fileType = new LoadTestingFileType(prop.Value.GetString()); continue; } - if (property.NameEquals("expireDateTime"u8)) + if (prop.NameEquals("expireDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - expireDateTime = property.Value.GetDateTimeOffset("O"); + expiresOn = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("validationStatus"u8)) + if (prop.NameEquals("validationStatus"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - validationStatus = new FileValidationStatus(property.Value.GetString()); + validationStatus = new FileValidationStatus(prop.Value.GetString()); continue; } - if (property.NameEquals("validationFailureDetails"u8)) + if (prop.NameEquals("validationFailureDetails"u8)) { - validationFailureDetails = property.Value.GetString(); + validationFailureDetails = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new TestFileInfo( fileName, - url, + uri, fileType, - expireDateTime, + expiresOn, validationStatus, validationFailureDetails, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -183,15 +194,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions option } } - TestFileInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestFileInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestFileInfo PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestFileInfo(document.RootElement, options); } default: @@ -199,22 +215,14 @@ TestFileInfo IPersistableModel.Create(BinaryData data, ModelReader } } + /// The client options for reading and writing models. 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() + /// The to deserialize the from. + public static explicit operator TestFileInfo(Response response) { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); - return content; + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestFileInfo(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestFileInfo.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestFileInfo.cs index f8565ac4492c..529b1acaf50d 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestFileInfo.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestFileInfo.cs @@ -13,45 +13,13 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// Name of the file. - /// is null. internal TestFileInfo(string fileName) { - Argument.AssertNotNull(fileName, nameof(fileName)); - FileName = fileName; } @@ -62,8 +30,8 @@ internal TestFileInfo(string fileName) /// 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) + /// Keeps track of any properties unknown to the library. + internal TestFileInfo(string fileName, Uri uri, LoadTestingFileType? fileType, DateTimeOffset? expiresOn, FileValidationStatus? validationStatus, string validationFailureDetails, IDictionary additionalBinaryDataProperties) { FileName = fileName; Uri = uri; @@ -71,24 +39,24 @@ internal TestFileInfo(string fileName, Uri uri, LoadTestingFileType? fileType, D ExpiresOn = expiresOn; ValidationStatus = validationStatus; ValidationFailureDetails = validationFailureDetails; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal TestFileInfo() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestInputArtifacts.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestInputArtifacts.Serialization.cs index a777253a9d6b..327fd53ef630 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestInputArtifacts.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestInputArtifacts.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// The input artifacts for the test. + public partial class TestInputArtifacts : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit /// 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; + string 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); @@ -63,21 +62,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("additionalFileInfo"u8); writer.WriteStartArray(); - foreach (var item in AdditionalFileInfo) + foreach (TestFileInfo item in AdditionalFileInfo) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -86,89 +85,93 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestInputArtifacts IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestInputArtifacts IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestInputArtifacts JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestInputArtifacts DeserializeTestInputArtifacts(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } TestFileInfo configFileInfo = default; TestFileInfo testScriptFileInfo = default; - TestFileInfo userPropFileInfo = default; + TestFileInfo userPropertyFileInfo = default; TestFileInfo inputArtifactsZipFileInfo = default; TestFileInfo urlTestConfigFileInfo = default; IReadOnlyList additionalFileInfo = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("configFileInfo"u8)) + if (prop.NameEquals("configFileInfo"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - configFileInfo = TestFileInfo.DeserializeTestFileInfo(property.Value, options); + configFileInfo = TestFileInfo.DeserializeTestFileInfo(prop.Value, options); continue; } - if (property.NameEquals("testScriptFileInfo"u8)) + if (prop.NameEquals("testScriptFileInfo"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - testScriptFileInfo = TestFileInfo.DeserializeTestFileInfo(property.Value, options); + testScriptFileInfo = TestFileInfo.DeserializeTestFileInfo(prop.Value, options); continue; } - if (property.NameEquals("userPropFileInfo"u8)) + if (prop.NameEquals("userPropFileInfo"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - userPropFileInfo = TestFileInfo.DeserializeTestFileInfo(property.Value, options); + userPropertyFileInfo = TestFileInfo.DeserializeTestFileInfo(prop.Value, options); continue; } - if (property.NameEquals("inputArtifactsZipFileInfo"u8)) + if (prop.NameEquals("inputArtifactsZipFileInfo"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - inputArtifactsZipFileInfo = TestFileInfo.DeserializeTestFileInfo(property.Value, options); + inputArtifactsZipFileInfo = TestFileInfo.DeserializeTestFileInfo(prop.Value, options); continue; } - if (property.NameEquals("urlTestConfigFileInfo"u8)) + if (prop.NameEquals("urlTestConfigFileInfo"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - urlTestConfigFileInfo = TestFileInfo.DeserializeTestFileInfo(property.Value, options); + urlTestConfigFileInfo = TestFileInfo.DeserializeTestFileInfo(prop.Value, options); continue; } - if (property.NameEquals("additionalFileInfo"u8)) + if (prop.NameEquals("additionalFileInfo"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(TestFileInfo.DeserializeTestFileInfo(item, options)); } @@ -177,24 +180,26 @@ internal static TestInputArtifacts DeserializeTestInputArtifacts(JsonElement ele } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new TestInputArtifacts( configFileInfo, testScriptFileInfo, - userPropFileInfo, + userPropertyFileInfo, inputArtifactsZipFileInfo, urlTestConfigFileInfo, additionalFileInfo ?? new ChangeTrackingList(), - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -204,15 +209,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - TestInputArtifacts IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestInputArtifacts IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestInputArtifacts PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestInputArtifacts(document.RootElement, options); } default: @@ -220,22 +230,7 @@ TestInputArtifacts IPersistableModel.Create(BinaryData data, } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestInputArtifacts.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestInputArtifacts.cs index f59c5a94183f..73d2c5a86f45 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestInputArtifacts.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestInputArtifacts.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal TestInputArtifacts() @@ -58,8 +29,8 @@ internal TestInputArtifacts() /// 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) + /// Keeps track of any properties unknown to the library. + internal TestInputArtifacts(TestFileInfo configFileInfo, TestFileInfo testScriptFileInfo, TestFileInfo userPropertyFileInfo, TestFileInfo inputArtifactsZipFileInfo, TestFileInfo urlTestConfigFileInfo, IReadOnlyList additionalFileInfo, IDictionary additionalBinaryDataProperties) { ConfigFileInfo = configFileInfo; TestScriptFileInfo = testScriptFileInfo; @@ -67,19 +38,24 @@ internal TestInputArtifacts(TestFileInfo configFileInfo, TestFileInfo testScript InputArtifactsZipFileInfo = inputArtifactsZipFileInfo; UrlTestConfigFileInfo = urlTestConfigFileInfo; AdditionalFileInfo = additionalFileInfo; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfile.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfile.Serialization.cs index 7b6acfe27393..db5748228418 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfile.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfile.Serialization.cs @@ -9,14 +9,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure; using Azure.Core; namespace Azure.Developer.LoadTesting { - public partial class TestProfile : IUtf8JsonSerializable, IJsonModel + /// Test Profile Model. + public partial class TestProfile : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +30,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptio /// 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; + string 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); @@ -84,15 +85,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("lastModifiedBy"u8); writer.WriteStringValue(LastModifiedBy); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -101,22 +102,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestProfile JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestProfile DeserializeTestProfile(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -131,82 +137,80 @@ internal static TestProfile DeserializeTestProfile(JsonElement element, ModelRea string createdBy = default; DateTimeOffset? lastModifiedDateTime = default; string lastModifiedBy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("testProfileId"u8)) + if (prop.NameEquals("testProfileId"u8)) { - testProfileId = property.Value.GetString(); + testProfileId = prop.Value.GetString(); continue; } - if (property.NameEquals("displayName"u8)) + if (prop.NameEquals("displayName"u8)) { - displayName = property.Value.GetString(); + displayName = prop.Value.GetString(); continue; } - if (property.NameEquals("description"u8)) + if (prop.NameEquals("description"u8)) { - description = property.Value.GetString(); + description = prop.Value.GetString(); continue; } - if (property.NameEquals("testId"u8)) + if (prop.NameEquals("testId"u8)) { - testId = property.Value.GetString(); + testId = prop.Value.GetString(); continue; } - if (property.NameEquals("targetResourceId"u8)) + if (prop.NameEquals("targetResourceId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - targetResourceId = new ResourceIdentifier(property.Value.GetString()); + targetResourceId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("targetResourceConfigurations"u8)) + if (prop.NameEquals("targetResourceConfigurations"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - targetResourceConfigurations = TargetResourceConfigurations.DeserializeTargetResourceConfigurations(property.Value, options); + targetResourceConfigurations = TargetResourceConfigurations.DeserializeTargetResourceConfigurations(prop.Value, options); continue; } - if (property.NameEquals("createdDateTime"u8)) + if (prop.NameEquals("createdDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - createdDateTime = property.Value.GetDateTimeOffset("O"); + createdDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("createdBy"u8)) + if (prop.NameEquals("createdBy"u8)) { - createdBy = property.Value.GetString(); + createdBy = prop.Value.GetString(); continue; } - if (property.NameEquals("lastModifiedDateTime"u8)) + if (prop.NameEquals("lastModifiedDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + lastModifiedDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("lastModifiedBy"u8)) + if (prop.NameEquals("lastModifiedBy"u8)) { - lastModifiedBy = property.Value.GetString(); + lastModifiedBy = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new TestProfile( testProfileId, displayName, @@ -218,13 +222,16 @@ internal static TestProfile DeserializeTestProfile(JsonElement element, ModelRea createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -234,15 +241,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options } } - TestProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestProfile PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestProfile(document.RootElement, options); } default: @@ -250,22 +262,14 @@ TestProfile IPersistableModel.Create(BinaryData data, ModelReaderWr } } + /// The client options for reading and writing models. 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() + /// The to deserialize the from. + public static explicit operator TestProfile(Response response) { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); - return content; + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestProfile(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfile.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfile.cs index 1148abffddfd..14ea688a545d 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfile.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfile.cs @@ -11,40 +11,11 @@ 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. + /// Test Profile Model. 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public TestProfile() @@ -57,17 +28,13 @@ public TestProfile() /// 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 . - /// + /// Configurations of the target resource on which testing would be done. /// 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) + /// 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 additionalBinaryDataProperties) { TestProfileId = testProfileId; DisplayName = displayName; @@ -79,31 +46,36 @@ internal TestProfile(string testProfileId, string displayName, string descriptio CreatedBy = createdBy; LastModifiedDateTime = lastModifiedDateTime; LastModifiedBy = lastModifiedBy; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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 . - /// + + /// Configurations of the target resource on which testing would be done. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRun.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRun.Serialization.cs index 192fef4cb393..0c42ce69cbb6 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRun.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRun.Serialization.cs @@ -9,14 +9,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure; using Azure.Core; namespace Azure.Developer.LoadTesting { - public partial class TestProfileRun : IUtf8JsonSerializable, IJsonModel + /// Test Profile Run model. + public partial class TestProfileRun : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +30,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp /// 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; + string 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); @@ -73,7 +74,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("errorDetails"u8); writer.WriteStartArray(); - foreach (var item in ErrorDetails) + foreach (ErrorDetails item in ErrorDetails) { writer.WriteObjectValue(item, options); } @@ -109,7 +110,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("recommendations"u8); writer.WriteStartArray(); - foreach (var item in Recommendations) + foreach (TestProfileRunRecommendation item in Recommendations) { writer.WriteObjectValue(item, options); } @@ -135,15 +136,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("lastModifiedBy"u8); writer.WriteStringValue(LastModifiedBy); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -152,22 +153,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestProfileRun IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestProfileRun IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestProfileRun JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestProfileRun DeserializeTestProfileRun(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -189,160 +195,158 @@ internal static TestProfileRun DeserializeTestProfileRun(JsonElement element, Mo string createdBy = default; DateTimeOffset? lastModifiedDateTime = default; string lastModifiedBy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("testProfileRunId"u8)) + if (prop.NameEquals("testProfileRunId"u8)) { - testProfileRunId = property.Value.GetString(); + testProfileRunId = prop.Value.GetString(); continue; } - if (property.NameEquals("displayName"u8)) + if (prop.NameEquals("displayName"u8)) { - displayName = property.Value.GetString(); + displayName = prop.Value.GetString(); continue; } - if (property.NameEquals("description"u8)) + if (prop.NameEquals("description"u8)) { - description = property.Value.GetString(); + description = prop.Value.GetString(); continue; } - if (property.NameEquals("testProfileId"u8)) + if (prop.NameEquals("testProfileId"u8)) { - testProfileId = property.Value.GetString(); + testProfileId = prop.Value.GetString(); continue; } - if (property.NameEquals("targetResourceId"u8)) + if (prop.NameEquals("targetResourceId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - targetResourceId = new ResourceIdentifier(property.Value.GetString()); + targetResourceId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("targetResourceConfigurations"u8)) + if (prop.NameEquals("targetResourceConfigurations"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - targetResourceConfigurations = TargetResourceConfigurations.DeserializeTargetResourceConfigurations(property.Value, options); + targetResourceConfigurations = TargetResourceConfigurations.DeserializeTargetResourceConfigurations(prop.Value, options); continue; } - if (property.NameEquals("status"u8)) + if (prop.NameEquals("status"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - status = new TestProfileRunStatus(property.Value.GetString()); + status = new TestProfileRunStatus(prop.Value.GetString()); continue; } - if (property.NameEquals("errorDetails"u8)) + if (prop.NameEquals("errorDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(LoadTesting.ErrorDetails.DeserializeErrorDetails(item, options)); } errorDetails = array; continue; } - if (property.NameEquals("startDateTime"u8)) + if (prop.NameEquals("startDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - startDateTime = property.Value.GetDateTimeOffset("O"); + startDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("endDateTime"u8)) + if (prop.NameEquals("endDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - endDateTime = property.Value.GetDateTimeOffset("O"); + endDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("durationInSeconds"u8)) + if (prop.NameEquals("durationInSeconds"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - durationInSeconds = property.Value.GetInt64(); + durationInSeconds = prop.Value.GetInt64(); continue; } - if (property.NameEquals("testRunDetails"u8)) + if (prop.NameEquals("testRunDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, TestRunDetail.DeserializeTestRunDetail(property0.Value, options)); + dictionary.Add(prop0.Name, TestRunDetail.DeserializeTestRunDetail(prop0.Value, options)); } testRunDetails = dictionary; continue; } - if (property.NameEquals("recommendations"u8)) + if (prop.NameEquals("recommendations"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(TestProfileRunRecommendation.DeserializeTestProfileRunRecommendation(item, options)); } recommendations = array; continue; } - if (property.NameEquals("createdDateTime"u8)) + if (prop.NameEquals("createdDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - createdDateTime = property.Value.GetDateTimeOffset("O"); + createdDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("createdBy"u8)) + if (prop.NameEquals("createdBy"u8)) { - createdBy = property.Value.GetString(); + createdBy = prop.Value.GetString(); continue; } - if (property.NameEquals("lastModifiedDateTime"u8)) + if (prop.NameEquals("lastModifiedDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + lastModifiedDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("lastModifiedBy"u8)) + if (prop.NameEquals("lastModifiedBy"u8)) { - lastModifiedBy = property.Value.GetString(); + lastModifiedBy = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new TestProfileRun( testProfileRunId, displayName, @@ -361,13 +365,16 @@ internal static TestProfileRun DeserializeTestProfileRun(JsonElement element, Mo createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -377,15 +384,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opti } } - TestProfileRun IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestProfileRun IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestProfileRun PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestProfileRun(document.RootElement, options); } default: @@ -393,22 +405,14 @@ TestProfileRun IPersistableModel.Create(BinaryData data, ModelRe } } + /// The client options for reading and writing models. 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() + /// The to deserialize the from. + public static explicit operator TestProfileRun(Response response) { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); - return content; + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestProfileRun(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRun.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRun.cs index c48bc4d85bdf..b0d8fc98359a 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRun.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRun.cs @@ -11,40 +11,11 @@ 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. + /// Test Profile Run model. 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public TestProfileRun() @@ -60,11 +31,7 @@ public TestProfileRun() /// 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 . - /// + /// Configurations of the target resource on which the test profile ran. /// 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). @@ -79,8 +46,8 @@ public TestProfileRun() /// 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) + /// 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 additionalBinaryDataProperties) { TestProfileRunId = testProfileRunId; DisplayName = displayName; @@ -99,48 +66,60 @@ internal TestProfileRun(string testProfileRunId, string displayName, string desc CreatedBy = createdBy; LastModifiedDateTime = lastModifiedDateTime; LastModifiedBy = lastModifiedBy; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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 . - /// + + /// Configurations of the target resource on which the test profile ran. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRunRecommendation.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRunRecommendation.Serialization.cs index 8176ea801f92..b2f95ab3f18c 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRunRecommendation.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRunRecommendation.Serialization.cs @@ -9,14 +9,19 @@ 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 + /// A recommendation object that provides a list of configuration that optimizes its category. + public partial class TestProfileRunRecommendation : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TestProfileRunRecommendation() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,33 +33,37 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model /// 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; + string 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) + foreach (string item in Configurations) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -63,64 +72,77 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestProfileRunRecommendation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestProfileRunRecommendation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestProfileRunRecommendation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestProfileRunRecommendation DeserializeTestProfileRunRecommendation(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IList configurations = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("category"u8)) + if (prop.NameEquals("category"u8)) { - category = new RecommendationCategory(property.Value.GetString()); + category = new RecommendationCategory(prop.Value.GetString()); continue; } - if (property.NameEquals("configurations"u8)) + if (prop.NameEquals("configurations"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { - array.Add(item.GetString()); + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } } configurations = array; continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TestProfileRunRecommendation(category, configurations ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new TestProfileRunRecommendation(category, configurations ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -130,15 +152,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - TestProfileRunRecommendation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestProfileRunRecommendation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestProfileRunRecommendation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestProfileRunRecommendation(document.RootElement, options); } default: @@ -146,22 +173,7 @@ TestProfileRunRecommendation IPersistableModel.Cre } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRunRecommendation.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRunRecommendation.cs index 0ffa550c782b..85383a3d3d3a 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRunRecommendation.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRunRecommendation.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// Category of the recommendation. @@ -56,22 +27,18 @@ internal TestProfileRunRecommendation(RecommendationCategory category) /// 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) + /// Keeps track of any properties unknown to the library. + internal TestProfileRunRecommendation(RecommendationCategory category, IList configurations, IDictionary additionalBinaryDataProperties) { Category = category; Configurations = configurations; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal TestProfileRunRecommendation() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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; } + public IList Configurations { get; } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRunStatus.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRunStatus.cs index e7bd29c606fc..17739b4a66a7 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRunStatus.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestProfileRunStatus.cs @@ -14,53 +14,82 @@ namespace Azure.Developer.LoadTesting 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)); - } - + /// Test profile run request is accepted. private const string AcceptedValue = "ACCEPTED"; + /// Test profile run is not yet started. private const string NotStartedValue = "NOTSTARTED"; + /// Test profile run has started executing. private const string ExecutingValue = "EXECUTING"; + /// Test profile run has completed successfully. private const string DoneValue = "DONE"; + /// Test profile run is being cancelled. private const string CancellingValue = "CANCELLING"; + /// Test profile run is cancelled. private const string CancelledValue = "CANCELLED"; + /// Test profile run has failed. private const string FailedValue = "FAILED"; + /// Initializes a new instance of . + /// The value. + /// is null. + public TestProfileRunStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TestProfileRunStatus left, TestProfileRunStatus right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(TestProfileRunStatus left, TestProfileRunStatus right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TestProfileRunStatus(string value) => new TestProfileRunStatus(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TestProfileRunStatus?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunAppComponents.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunAppComponents.Serialization.cs index cb62f8701e66..049e6efb6206 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunAppComponents.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunAppComponents.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; namespace Azure.Developer.LoadTesting { - public partial class TestRunAppComponents : IUtf8JsonSerializable, IJsonModel + /// Test run app component. + public partial class TestRunAppComponents : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TestRunAppComponents() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +34,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr /// 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; + string 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) @@ -67,15 +72,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("lastModifiedBy"u8); writer.WriteStringValue(LastModifiedBy); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -84,22 +89,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestRunAppComponents IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestRunAppComponents IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestRunAppComponents JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestRunAppComponents DeserializeTestRunAppComponents(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -110,59 +120,57 @@ internal static TestRunAppComponents DeserializeTestRunAppComponents(JsonElement string createdBy = default; DateTimeOffset? lastModifiedDateTime = default; string lastModifiedBy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("components"u8)) + if (prop.NameEquals("components"u8)) { Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, LoadTestingAppComponent.DeserializeLoadTestingAppComponent(property0.Value, options)); + dictionary.Add(prop0.Name, LoadTestingAppComponent.DeserializeLoadTestingAppComponent(prop0.Value, options)); } components = dictionary; continue; } - if (property.NameEquals("testRunId"u8)) + if (prop.NameEquals("testRunId"u8)) { - testRunId = property.Value.GetString(); + testRunId = prop.Value.GetString(); continue; } - if (property.NameEquals("createdDateTime"u8)) + if (prop.NameEquals("createdDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - createdDateTime = property.Value.GetDateTimeOffset("O"); + createdDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("createdBy"u8)) + if (prop.NameEquals("createdBy"u8)) { - createdBy = property.Value.GetString(); + createdBy = prop.Value.GetString(); continue; } - if (property.NameEquals("lastModifiedDateTime"u8)) + if (prop.NameEquals("lastModifiedDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + lastModifiedDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("lastModifiedBy"u8)) + if (prop.NameEquals("lastModifiedBy"u8)) { - lastModifiedBy = property.Value.GetString(); + lastModifiedBy = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new TestRunAppComponents( components, testRunId, @@ -170,13 +178,16 @@ internal static TestRunAppComponents DeserializeTestRunAppComponents(JsonElement createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -186,15 +197,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption } } - TestRunAppComponents IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestRunAppComponents IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestRunAppComponents PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestRunAppComponents(document.RootElement, options); } default: @@ -202,22 +218,14 @@ TestRunAppComponents IPersistableModel.Create(BinaryData d } } + /// The client options for reading and writing models. 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() + /// The to deserialize the from. + public static explicit operator TestRunAppComponents(Response response) { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); - return content; + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestRunAppComponents(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunAppComponents.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunAppComponents.cs index 7df877f94aab..5c6a231ab090 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunAppComponents.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunAppComponents.cs @@ -13,43 +13,14 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// 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 } + /// : resource object } /// /// is null. public TestRunAppComponents(IDictionary components) @@ -63,15 +34,15 @@ public TestRunAppComponents(IDictionary compone /// /// Azure resource collection { resource id (fully qualified resource Id e.g /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) - /// : resource object } + /// : 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) + /// Keeps track of any properties unknown to the library. + internal TestRunAppComponents(IDictionary components, string testRunId, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary additionalBinaryDataProperties) { Components = components; TestRunId = testRunId; @@ -79,28 +50,28 @@ internal TestRunAppComponents(IDictionary compo CreatedBy = createdBy; LastModifiedDateTime = lastModifiedDateTime; LastModifiedBy = lastModifiedBy; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal TestRunAppComponents() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// /// Azure resource collection { resource id (fully qualified resource Id e.g /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) - /// : resource object } + /// : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunArtifacts.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunArtifacts.Serialization.cs index b5fe8a908e3d..46dfbb77df4c 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunArtifacts.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunArtifacts.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Collection of test run artifacts. + public partial class TestRunArtifacts : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter /// 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; + string 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); @@ -44,15 +43,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("outputArtifacts"u8); writer.WriteObjectValue(OutputArtifacts, options); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,63 +60,69 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestRunArtifacts IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestRunArtifacts IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestRunArtifacts JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestRunArtifacts DeserializeTestRunArtifacts(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("inputArtifacts"u8)) + if (prop.NameEquals("inputArtifacts"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - inputArtifacts = TestRunInputArtifacts.DeserializeTestRunInputArtifacts(property.Value, options); + inputArtifacts = TestRunInputArtifacts.DeserializeTestRunInputArtifacts(prop.Value, options); continue; } - if (property.NameEquals("outputArtifacts"u8)) + if (prop.NameEquals("outputArtifacts"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - outputArtifacts = TestRunOutputArtifacts.DeserializeTestRunOutputArtifacts(property.Value, options); + outputArtifacts = TestRunOutputArtifacts.DeserializeTestRunOutputArtifacts(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TestRunArtifacts(inputArtifacts, outputArtifacts, serializedAdditionalRawData); + return new TestRunArtifacts(inputArtifacts, outputArtifacts, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -127,15 +132,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions op } } - TestRunArtifacts IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestRunArtifacts IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestRunArtifacts PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestRunArtifacts(document.RootElement, options); } default: @@ -143,22 +153,7 @@ TestRunArtifacts IPersistableModel.Create(BinaryData data, Mod } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunArtifacts.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunArtifacts.cs index ebf85cfa6567..f983d14d091a 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunArtifacts.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunArtifacts.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal TestRunArtifacts() @@ -53,16 +24,17 @@ 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) + /// Keeps track of any properties unknown to the library. + internal TestRunArtifacts(TestRunInputArtifacts inputArtifacts, TestRunOutputArtifacts outputArtifacts, IDictionary additionalBinaryDataProperties) { InputArtifacts = inputArtifacts; OutputArtifacts = outputArtifacts; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunDetail.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunDetail.Serialization.cs index 0de21ae08f28..1130e60c57ee 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunDetail.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunDetail.Serialization.cs @@ -9,14 +9,19 @@ 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 + /// Details of a particular test run for a test profile run. + public partial class TestRunDetail : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TestRunDetail() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +33,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt /// 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; + string 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); @@ -43,18 +47,23 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit foreach (var item in Properties) { writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item.Value); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -63,66 +72,79 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestRunDetail IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestRunDetail IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestRunDetail JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestRunDetail DeserializeTestRunDetail(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary properties = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("status"u8)) + if (prop.NameEquals("status"u8)) { - status = new TestRunStatus(property.Value.GetString()); + status = new TestRunStatus(prop.Value.GetString()); continue; } - if (property.NameEquals("configurationId"u8)) + if (prop.NameEquals("configurationId"u8)) { - configurationId = property.Value.GetString(); + configurationId = prop.Value.GetString(); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("properties"u8)) { Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, property0.Value.GetString()); + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } } properties = dictionary; continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TestRunDetail(status, configurationId, properties, serializedAdditionalRawData); + return new TestRunDetail(status, configurationId, properties, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -132,15 +154,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions optio } } - TestRunDetail IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestRunDetail IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestRunDetail PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestRunDetail(document.RootElement, options); } default: @@ -148,22 +175,7 @@ TestRunDetail IPersistableModel.Create(BinaryData data, ModelRead } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunDetail.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunDetail.cs index 2be47512ac2b..55f05c65a642 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunDetail.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunDetail.cs @@ -13,48 +13,15 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// 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) + internal TestRunDetail(TestRunStatus status, string configurationId, IDictionary properties) { - Argument.AssertNotNull(configurationId, nameof(configurationId)); - Argument.AssertNotNull(properties, nameof(properties)); - Status = status; ConfigurationId = configurationId; Properties = properties; @@ -64,25 +31,22 @@ internal TestRunDetail(TestRunStatus status, string configurationId, IReadOnlyDi /// 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) + /// Keeps track of any properties unknown to the library. + internal TestRunDetail(TestRunStatus status, string configurationId, IDictionary properties, IDictionary additionalBinaryDataProperties) { Status = status; ConfigurationId = configurationId; Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal TestRunDetail() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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; } + public IDictionary Properties { get; } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunEndedEventCondition.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunEndedEventCondition.Serialization.cs index fd887e84db19..93406b375e07 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunEndedEventCondition.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunEndedEventCondition.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// TestRunEnded Event condition. + public partial class TestRunEndedEventCondition : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,17 +28,16 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe /// 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; + string 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) + foreach (TestRunStatus item in TestRunStatuses) { writer.WriteStringValue(item.ToString()); } @@ -48,21 +47,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("testRunResults"u8); writer.WriteStartArray(); - foreach (var item in TestRunResults) + foreach (PassFailTestResult item in TestRunResults) { writer.WriteStringValue(item.ToString()); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -71,54 +70,58 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestRunEndedEventCondition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestRunEndedEventCondition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestRunEndedEventCondition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestRunEndedEventCondition DeserializeTestRunEndedEventCondition(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("testRunStatuses"u8)) + if (prop.NameEquals("testRunStatuses"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(new TestRunStatus(item.GetString())); } testRunStatuses = array; continue; } - if (property.NameEquals("testRunResults"u8)) + if (prop.NameEquals("testRunResults"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(new PassFailTestResult(item.GetString())); } @@ -127,17 +130,19 @@ internal static TestRunEndedEventCondition DeserializeTestRunEndedEventCondition } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TestRunEndedEventCondition(testRunStatuses ?? new ChangeTrackingList(), testRunResults ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new TestRunEndedEventCondition(testRunStatuses ?? new ChangeTrackingList(), testRunResults ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -147,15 +152,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriter } } - TestRunEndedEventCondition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestRunEndedEventCondition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestRunEndedEventCondition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestRunEndedEventCondition(document.RootElement, options); } default: @@ -163,22 +173,7 @@ TestRunEndedEventCondition IPersistableModel.Create( } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunEndedEventCondition.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunEndedEventCondition.cs index 62f7e4e10c37..171b66362d67 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunEndedEventCondition.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunEndedEventCondition.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public TestRunEndedEventCondition() @@ -55,16 +26,17 @@ public TestRunEndedEventCondition() /// 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) + /// Keeps track of any properties unknown to the library. + internal TestRunEndedEventCondition(IList testRunStatuses, IList testRunResults, IDictionary additionalBinaryDataProperties) { TestRunStatuses = testRunStatuses; TestRunResults = testRunResults; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunEndedNotificationEventFilter.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunEndedNotificationEventFilter.Serialization.cs index 4a2924b83322..0dd103305d39 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunEndedNotificationEventFilter.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunEndedNotificationEventFilter.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// The notification event filter when the event type is TestRunEnded and scope is Tests. + public partial class TestRunEndedNotificationEventFilter : TestsNotificationEventFilter, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter 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; + string 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)) { @@ -42,59 +41,65 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - TestRunEndedNotificationEventFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestRunEndedNotificationEventFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TestRunEndedNotificationEventFilter)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TestsNotificationEventFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestRunEndedNotificationEventFilter DeserializeTestRunEndedNotificationEventFilter(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + TestRunEndedEventCondition condition = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("condition"u8)) + if (prop.NameEquals("kind"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - condition = TestRunEndedEventCondition.DeserializeTestRunEndedEventCondition(property.Value, options); + kind = new NotificationEventType(prop.Value.GetString()); continue; } - if (property.NameEquals("kind"u8)) + if (prop.NameEquals("condition"u8)) { - kind = new NotificationEventType(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + condition = TestRunEndedEventCondition.DeserializeTestRunEndedEventCondition(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TestRunEndedNotificationEventFilter(kind, serializedAdditionalRawData, condition); + return new TestRunEndedNotificationEventFilter(kind, additionalBinaryDataProperties, condition); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -104,15 +109,20 @@ BinaryData IPersistableModel.Write(ModelRea } } - TestRunEndedNotificationEventFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestRunEndedNotificationEventFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TestRunEndedNotificationEventFilter)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override TestsNotificationEventFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestRunEndedNotificationEventFilter(document.RootElement, options); } default: @@ -120,22 +130,7 @@ TestRunEndedNotificationEventFilter IPersistableModel The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunEndedNotificationEventFilter.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunEndedNotificationEventFilter.cs index e3d4eeb87020..e99c9850c64d 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunEndedNotificationEventFilter.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunEndedNotificationEventFilter.cs @@ -14,16 +14,15 @@ namespace Azure.Developer.LoadTesting public partial class TestRunEndedNotificationEventFilter : TestsNotificationEventFilter { /// Initializes a new instance of . - public TestRunEndedNotificationEventFilter() + public TestRunEndedNotificationEventFilter() : base(NotificationEventType.TestRunEnded) { - Kind = NotificationEventType.TestRunEnded; } /// Initializes a new instance of . /// The event type. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Event filtering condition. - internal TestRunEndedNotificationEventFilter(NotificationEventType kind, IDictionary serializedAdditionalRawData, TestRunEndedEventCondition condition) : base(kind, serializedAdditionalRawData) + internal TestRunEndedNotificationEventFilter(NotificationEventType kind, IDictionary additionalBinaryDataProperties, TestRunEndedEventCondition condition) : base(kind, additionalBinaryDataProperties) { Condition = condition; } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunFileInfo.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunFileInfo.Serialization.cs index 1f468fa8b50d..cc701fc907fb 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunFileInfo.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunFileInfo.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; namespace Azure.Developer.LoadTesting { - public partial class TestRunFileInfo : IUtf8JsonSerializable, IJsonModel + /// Test run file info. + public partial class TestRunFileInfo : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TestRunFileInfo() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +34,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO /// 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; + string 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)) @@ -61,15 +66,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("validationFailureDetails"u8); writer.WriteStringValue(ValidationFailureDetails); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -78,102 +83,108 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestRunFileInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestRunFileInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestRunFileInfo JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestRunFileInfo DeserializeTestRunFileInfo(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string fileName = default; - Uri url = default; + Uri uri = default; LoadTestingFileType? fileType = default; - DateTimeOffset? expireDateTime = default; + DateTimeOffset? expiresOn = default; FileValidationStatus? validationStatus = default; string validationFailureDetails = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("fileName"u8)) + if (prop.NameEquals("fileName"u8)) { - fileName = property.Value.GetString(); + fileName = prop.Value.GetString(); continue; } - if (property.NameEquals("url"u8)) + if (prop.NameEquals("url"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - url = new Uri(property.Value.GetString()); + uri = new Uri(prop.Value.GetString()); continue; } - if (property.NameEquals("fileType"u8)) + if (prop.NameEquals("fileType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - fileType = new LoadTestingFileType(property.Value.GetString()); + fileType = new LoadTestingFileType(prop.Value.GetString()); continue; } - if (property.NameEquals("expireDateTime"u8)) + if (prop.NameEquals("expireDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - expireDateTime = property.Value.GetDateTimeOffset("O"); + expiresOn = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("validationStatus"u8)) + if (prop.NameEquals("validationStatus"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - validationStatus = new FileValidationStatus(property.Value.GetString()); + validationStatus = new FileValidationStatus(prop.Value.GetString()); continue; } - if (property.NameEquals("validationFailureDetails"u8)) + if (prop.NameEquals("validationFailureDetails"u8)) { - validationFailureDetails = property.Value.GetString(); + validationFailureDetails = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new TestRunFileInfo( fileName, - url, + uri, fileType, - expireDateTime, + expiresOn, validationStatus, validationFailureDetails, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -183,15 +194,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opt } } - TestRunFileInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestRunFileInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestRunFileInfo PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestRunFileInfo(document.RootElement, options); } default: @@ -199,22 +215,14 @@ TestRunFileInfo IPersistableModel.Create(BinaryData data, Model } } + /// The client options for reading and writing models. 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() + /// The to deserialize the from. + public static explicit operator TestRunFileInfo(Response response) { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); - return content; + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestRunFileInfo(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunFileInfo.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunFileInfo.cs index 57896a725b79..f7d23ecad7e2 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunFileInfo.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunFileInfo.cs @@ -13,45 +13,13 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// Name of the file. - /// is null. internal TestRunFileInfo(string fileName) { - Argument.AssertNotNull(fileName, nameof(fileName)); - FileName = fileName; } @@ -62,8 +30,8 @@ internal TestRunFileInfo(string fileName) /// 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) + /// Keeps track of any properties unknown to the library. + internal TestRunFileInfo(string fileName, Uri uri, LoadTestingFileType? fileType, DateTimeOffset? expiresOn, FileValidationStatus? validationStatus, string validationFailureDetails, IDictionary additionalBinaryDataProperties) { FileName = fileName; Uri = uri; @@ -71,24 +39,24 @@ internal TestRunFileInfo(string fileName, Uri uri, LoadTestingFileType? fileType ExpiresOn = expiresOn; ValidationStatus = validationStatus; ValidationFailureDetails = validationFailureDetails; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal TestRunFileInfo() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInputArtifacts.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInputArtifacts.Serialization.cs index 0aa924b056f1..acefa8323fcd 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInputArtifacts.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInputArtifacts.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// The input artifacts for the test run. + public partial class TestRunInputArtifacts : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW /// 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; + string 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); @@ -63,21 +62,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("additionalFileInfo"u8); writer.WriteStartArray(); - foreach (var item in AdditionalFileInfo) + foreach (TestRunFileInfo item in AdditionalFileInfo) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -86,89 +85,93 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestRunInputArtifacts IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestRunInputArtifacts IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestRunInputArtifacts JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestRunInputArtifacts DeserializeTestRunInputArtifacts(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } TestRunFileInfo configFileInfo = default; TestRunFileInfo testScriptFileInfo = default; - TestRunFileInfo userPropFileInfo = default; + TestRunFileInfo userPropertyFileInfo = default; TestRunFileInfo inputArtifactsZipFileInfo = default; TestRunFileInfo urlTestConfigFileInfo = default; IReadOnlyList additionalFileInfo = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("configFileInfo"u8)) + if (prop.NameEquals("configFileInfo"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - configFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + configFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(prop.Value, options); continue; } - if (property.NameEquals("testScriptFileInfo"u8)) + if (prop.NameEquals("testScriptFileInfo"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - testScriptFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + testScriptFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(prop.Value, options); continue; } - if (property.NameEquals("userPropFileInfo"u8)) + if (prop.NameEquals("userPropFileInfo"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - userPropFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + userPropertyFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(prop.Value, options); continue; } - if (property.NameEquals("inputArtifactsZipFileInfo"u8)) + if (prop.NameEquals("inputArtifactsZipFileInfo"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - inputArtifactsZipFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + inputArtifactsZipFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(prop.Value, options); continue; } - if (property.NameEquals("urlTestConfigFileInfo"u8)) + if (prop.NameEquals("urlTestConfigFileInfo"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - urlTestConfigFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + urlTestConfigFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(prop.Value, options); continue; } - if (property.NameEquals("additionalFileInfo"u8)) + if (prop.NameEquals("additionalFileInfo"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(TestRunFileInfo.DeserializeTestRunFileInfo(item, options)); } @@ -177,24 +180,26 @@ internal static TestRunInputArtifacts DeserializeTestRunInputArtifacts(JsonEleme } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new TestRunInputArtifacts( configFileInfo, testScriptFileInfo, - userPropFileInfo, + userPropertyFileInfo, inputArtifactsZipFileInfo, urlTestConfigFileInfo, additionalFileInfo ?? new ChangeTrackingList(), - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -204,15 +209,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - TestRunInputArtifacts IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestRunInputArtifacts IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestRunInputArtifacts PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestRunInputArtifacts(document.RootElement, options); } default: @@ -220,22 +230,7 @@ TestRunInputArtifacts IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInputArtifacts.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInputArtifacts.cs index bc2161dfff03..2da3dd25f323 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInputArtifacts.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInputArtifacts.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal TestRunInputArtifacts() @@ -58,8 +29,8 @@ internal TestRunInputArtifacts() /// 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) + /// Keeps track of any properties unknown to the library. + internal TestRunInputArtifacts(TestRunFileInfo configFileInfo, TestRunFileInfo testScriptFileInfo, TestRunFileInfo userPropertyFileInfo, TestRunFileInfo inputArtifactsZipFileInfo, TestRunFileInfo urlTestConfigFileInfo, IReadOnlyList additionalFileInfo, IDictionary additionalBinaryDataProperties) { ConfigFileInfo = configFileInfo; TestScriptFileInfo = testScriptFileInfo; @@ -67,19 +38,24 @@ internal TestRunInputArtifacts(TestRunFileInfo configFileInfo, TestRunFileInfo t InputArtifactsZipFileInfo = inputArtifactsZipFileInfo; UrlTestConfigFileInfo = urlTestConfigFileInfo; AdditionalFileInfo = additionalFileInfo; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInsightColumn.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInsightColumn.Serialization.cs index a963fbbef32d..4f33a75ac9c0 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInsightColumn.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInsightColumn.Serialization.cs @@ -9,14 +9,19 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; namespace Azure.Developer.LoadTesting { - public partial class TestRunInsightColumn : IUtf8JsonSerializable, IJsonModel + /// Represents a column of the test run insight. + public partial class TestRunInsightColumn : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TestRunInsightColumn() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,25 +33,24 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TestRunInsightColumn)} does not support writing '{format}' format."); } - writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); writer.WritePropertyName("dataType"u8); writer.WriteStringValue(DataType); - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -55,55 +59,61 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestRunInsightColumn IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestRunInsightColumn IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestRunInsightColumn JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TestRunInsightColumn)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTestRunInsightColumn(document.RootElement, options); } - internal static TestRunInsightColumn DeserializeTestRunInsightColumn(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestRunInsightColumn DeserializeTestRunInsightColumn(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string name = default; string dataType = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("dataType"u8)) + if (prop.NameEquals("dataType"u8)) { - dataType = property.Value.GetString(); + dataType = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TestRunInsightColumn(name, dataType, serializedAdditionalRawData); + return new TestRunInsightColumn(name, dataType, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -113,15 +123,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption } } - TestRunInsightColumn IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestRunInsightColumn IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestRunInsightColumn PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestRunInsightColumn(document.RootElement, options); } default: @@ -129,22 +144,7 @@ TestRunInsightColumn IPersistableModel.Create(BinaryData d } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The response to deserialize the model from. - internal static TestRunInsightColumn FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTestRunInsightColumn(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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInsightColumn.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInsightColumn.cs index ed9523ddd591..0096f1d0ecd9 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInsightColumn.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInsightColumn.cs @@ -13,47 +13,14 @@ namespace Azure.Developer.LoadTesting /// Represents a column of the test run insight. public partial class TestRunInsightColumn { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// Name of the column. /// The data type of the column. - /// or is null. internal TestRunInsightColumn(string name, string dataType) { - Argument.AssertNotNull(name, nameof(name)); - Argument.AssertNotNull(dataType, nameof(dataType)); - Name = name; DataType = dataType; } @@ -61,21 +28,17 @@ internal TestRunInsightColumn(string name, string dataType) /// Initializes a new instance of . /// Name of the column. /// The data type of the column. - /// Keeps track of any properties unknown to the library. - internal TestRunInsightColumn(string name, string dataType, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TestRunInsightColumn(string name, string dataType, IDictionary additionalBinaryDataProperties) { Name = name; DataType = dataType; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal TestRunInsightColumn() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Name of the column. public string Name { get; } + /// The data type of the column. public string DataType { get; } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInsights.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInsights.Serialization.cs index fa31b09f086e..f041b48cc598 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInsights.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInsights.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; namespace Azure.Developer.LoadTesting { - public partial class TestRunInsights : IUtf8JsonSerializable, IJsonModel + /// Represents insights for the test run. + public partial class TestRunInsights : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,17 +29,16 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TestRunInsights)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsCollectionDefined(Columns)) { writer.WritePropertyName("columns"u8); writer.WriteStartArray(); - foreach (var item in Columns) + foreach (TestRunInsightColumn item in Columns) { writer.WriteObjectValue(item, options); } @@ -48,7 +48,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("rows"u8); writer.WriteStartArray(); - foreach (var item in Rows) + foreach (IDictionary item in Rows) { if (item == null) { @@ -59,6 +59,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit foreach (var item0 in item) { writer.WritePropertyName(item0.Key); + if (item0.Value == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item0.Value); } writer.WriteEndObject(); @@ -75,15 +80,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("status"u8); writer.WriteStringValue(Status.Value.ToString()); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -92,22 +97,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestRunInsights IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestRunInsights IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestRunInsights JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TestRunInsights)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTestRunInsights(document.RootElement, options); } - internal static TestRunInsights DeserializeTestRunInsights(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestRunInsights DeserializeTestRunInsights(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -116,32 +126,31 @@ internal static TestRunInsights DeserializeTestRunInsights(JsonElement element, IReadOnlyList> rows = default; long? version = default; OperationState? status = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("columns"u8)) + if (prop.NameEquals("columns"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(TestRunInsightColumn.DeserializeTestRunInsightColumn(item, options)); } columns = array; continue; } - if (property.NameEquals("rows"u8)) + if (prop.NameEquals("rows"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List> array = new List>(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { @@ -150,9 +159,16 @@ internal static TestRunInsights DeserializeTestRunInsights(JsonElement element, else { Dictionary dictionary = new Dictionary(); - foreach (var property0 in item.EnumerateObject()) + foreach (var prop0 in item.EnumerateObject()) { - dictionary.Add(property0.Name, property0.Value.GetString()); + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } } array.Add(dictionary); } @@ -160,37 +176,39 @@ internal static TestRunInsights DeserializeTestRunInsights(JsonElement element, rows = array; continue; } - if (property.NameEquals("version"u8)) + if (prop.NameEquals("version"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - version = property.Value.GetInt64(); + version = prop.Value.GetInt64(); continue; } - if (property.NameEquals("status"u8)) + if (prop.NameEquals("status"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - status = new OperationState(property.Value.GetString()); + status = new OperationState(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TestRunInsights(columns ?? new ChangeTrackingList(), rows ?? new ChangeTrackingList>(), version, status, serializedAdditionalRawData); + return new TestRunInsights(columns ?? new ChangeTrackingList(), rows ?? new ChangeTrackingList>(), version, status, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -200,15 +218,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opt } } - TestRunInsights IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestRunInsights IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestRunInsights PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestRunInsights(document.RootElement, options); } default: @@ -216,22 +239,14 @@ TestRunInsights IPersistableModel.Create(BinaryData data, Model } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The response to deserialize the model from. - internal static TestRunInsights FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTestRunInsights(document.RootElement); - } - - /// Convert into a . - internal virtual RequestContent ToRequestContent() + /// The to deserialize the from. + public static explicit operator TestRunInsights(Response response) { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); - return content; + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestRunInsights(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInsights.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInsights.cs index b88232dc201b..d7673a1ebf5b 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInsights.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunInsights.cs @@ -13,37 +13,8 @@ namespace Azure.Developer.LoadTesting /// Represents insights for the test run. public partial class TestRunInsights { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal TestRunInsights() @@ -57,22 +28,25 @@ internal TestRunInsights() /// The rows of the insights. /// The version of the insights. /// The status of the insights. - /// Keeps track of any properties unknown to the library. - internal TestRunInsights(IReadOnlyList columns, IReadOnlyList> rows, long? version, OperationState? status, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TestRunInsights(IReadOnlyList columns, IReadOnlyList> rows, long? version, OperationState? status, IDictionary additionalBinaryDataProperties) { Columns = columns; Rows = rows; Version = version; Status = status; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The columns of the insights. public IReadOnlyList Columns { get; } + /// The rows of the insights. public IReadOnlyList> Rows { get; } + /// The version of the insights. public long? Version { get; } + /// The status of the insights. public OperationState? Status { get; } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunOutputArtifacts.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunOutputArtifacts.Serialization.cs index 53fb2c6472ed..5f68b852446b 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunOutputArtifacts.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunOutputArtifacts.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// The output artifacts for the test run. + public partial class TestRunOutputArtifacts : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader /// 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; + string 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); @@ -54,15 +53,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("reportFileInfo"u8); writer.WriteObjectValue(ReportFileInfo, options); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -71,22 +70,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestRunOutputArtifacts IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestRunOutputArtifacts IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestRunOutputArtifacts JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestRunOutputArtifacts DeserializeTestRunOutputArtifacts(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -95,59 +99,60 @@ internal static TestRunOutputArtifacts DeserializeTestRunOutputArtifacts(JsonEle TestRunFileInfo logsFileInfo = default; ArtifactsContainerInfo artifactsContainerInfo = default; TestRunFileInfo reportFileInfo = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("resultFileInfo"u8)) + if (prop.NameEquals("resultFileInfo"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - resultFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + resultFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(prop.Value, options); continue; } - if (property.NameEquals("logsFileInfo"u8)) + if (prop.NameEquals("logsFileInfo"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - logsFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + logsFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(prop.Value, options); continue; } - if (property.NameEquals("artifactsContainerInfo"u8)) + if (prop.NameEquals("artifactsContainerInfo"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - artifactsContainerInfo = ArtifactsContainerInfo.DeserializeArtifactsContainerInfo(property.Value, options); + artifactsContainerInfo = ArtifactsContainerInfo.DeserializeArtifactsContainerInfo(prop.Value, options); continue; } - if (property.NameEquals("reportFileInfo"u8)) + if (prop.NameEquals("reportFileInfo"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - reportFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + reportFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TestRunOutputArtifacts(resultFileInfo, logsFileInfo, artifactsContainerInfo, reportFileInfo, serializedAdditionalRawData); + return new TestRunOutputArtifacts(resultFileInfo, logsFileInfo, artifactsContainerInfo, reportFileInfo, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -157,15 +162,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - TestRunOutputArtifacts IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestRunOutputArtifacts IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestRunOutputArtifacts PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestRunOutputArtifacts(document.RootElement, options); } default: @@ -173,22 +183,7 @@ TestRunOutputArtifacts IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunOutputArtifacts.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunOutputArtifacts.cs index 2d16a4940219..b04732bf383c 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunOutputArtifacts.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunOutputArtifacts.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal TestRunOutputArtifacts() @@ -55,22 +26,25 @@ internal TestRunOutputArtifacts() /// 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) + /// Keeps track of any properties unknown to the library. + internal TestRunOutputArtifacts(TestRunFileInfo resultFileInfo, TestRunFileInfo logsFileInfo, ArtifactsContainerInfo artifactsContainerInfo, TestRunFileInfo reportFileInfo, IDictionary additionalBinaryDataProperties) { ResultFileInfo = resultFileInfo; LogsFileInfo = logsFileInfo; ArtifactsContainerInfo = artifactsContainerInfo; ReportFileInfo = reportFileInfo; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunServerMetricsConfiguration.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunServerMetricsConfiguration.Serialization.cs index 44f6620609c5..e5f15e4bfeb9 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunServerMetricsConfiguration.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunServerMetricsConfiguration.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; namespace Azure.Developer.LoadTesting { - public partial class TestRunServerMetricsConfiguration : IUtf8JsonSerializable, IJsonModel + /// Test run server metrics configuration. + public partial class TestRunServerMetricsConfiguration : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter 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; + string 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); @@ -70,15 +70,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("lastModifiedBy"u8); writer.WriteStringValue(LastModifiedBy); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -87,22 +87,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestRunServerMetricsConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestRunServerMetricsConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestRunServerMetricsConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestRunServerMetricsConfiguration DeserializeTestRunServerMetricsConfiguration(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -113,63 +118,61 @@ internal static TestRunServerMetricsConfiguration DeserializeTestRunServerMetric string createdBy = default; DateTimeOffset? lastModifiedDateTime = default; string lastModifiedBy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("testRunId"u8)) + if (prop.NameEquals("testRunId"u8)) { - testRunId = property.Value.GetString(); + testRunId = prop.Value.GetString(); continue; } - if (property.NameEquals("metrics"u8)) + if (prop.NameEquals("metrics"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, ResourceMetric.DeserializeResourceMetric(property0.Value, options)); + dictionary.Add(prop0.Name, ResourceMetric.DeserializeResourceMetric(prop0.Value, options)); } metrics = dictionary; continue; } - if (property.NameEquals("createdDateTime"u8)) + if (prop.NameEquals("createdDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - createdDateTime = property.Value.GetDateTimeOffset("O"); + createdDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("createdBy"u8)) + if (prop.NameEquals("createdBy"u8)) { - createdBy = property.Value.GetString(); + createdBy = prop.Value.GetString(); continue; } - if (property.NameEquals("lastModifiedDateTime"u8)) + if (prop.NameEquals("lastModifiedDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + lastModifiedDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("lastModifiedBy"u8)) + if (prop.NameEquals("lastModifiedBy"u8)) { - lastModifiedBy = property.Value.GetString(); + lastModifiedBy = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new TestRunServerMetricsConfiguration( testRunId, metrics ?? new ChangeTrackingDictionary(), @@ -177,13 +180,16 @@ internal static TestRunServerMetricsConfiguration DeserializeTestRunServerMetric createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -193,15 +199,20 @@ BinaryData IPersistableModel.Write(ModelReade } } - TestRunServerMetricsConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestRunServerMetricsConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestRunServerMetricsConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestRunServerMetricsConfiguration(document.RootElement, options); } default: @@ -209,22 +220,14 @@ TestRunServerMetricsConfiguration IPersistableModel The client options for reading and writing models. 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() + /// The to deserialize the from. + public static explicit operator TestRunServerMetricsConfiguration(Response response) { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); - return content; + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestRunServerMetricsConfiguration(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunServerMetricsConfiguration.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunServerMetricsConfiguration.cs index b9a6d3ef0c4a..02e5c5c2a67d 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunServerMetricsConfiguration.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunServerMetricsConfiguration.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public TestRunServerMetricsConfiguration() @@ -62,8 +33,8 @@ public TestRunServerMetricsConfiguration() /// 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) + /// Keeps track of any properties unknown to the library. + internal TestRunServerMetricsConfiguration(string testRunId, IDictionary metrics, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary additionalBinaryDataProperties) { TestRunId = testRunId; Metrics = metrics; @@ -71,23 +42,28 @@ internal TestRunServerMetricsConfiguration(string testRunId, IDictionary 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStartedNotificationEventFilter.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStartedNotificationEventFilter.Serialization.cs index faa13238ca22..6a11068e417a 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStartedNotificationEventFilter.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStartedNotificationEventFilter.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// The notification event filter when the event type is TestRunStarted and scope is Tests. + public partial class TestRunStartedNotificationEventFilter : TestsNotificationEventFilter, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,58 +28,63 @@ void IJsonModel.Write(Utf8JsonWriter writ /// 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; + string 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) + /// The JSON reader. + /// The client options for reading and writing models. + TestRunStartedNotificationEventFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TestRunStartedNotificationEventFilter)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TestsNotificationEventFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestRunStartedNotificationEventFilter DeserializeTestRunStartedNotificationEventFilter(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("kind"u8)) + if (prop.NameEquals("kind"u8)) { - kind = new NotificationEventType(property.Value.GetString()); + kind = new NotificationEventType(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TestRunStartedNotificationEventFilter(kind, serializedAdditionalRawData); + return new TestRunStartedNotificationEventFilter(kind, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -89,15 +94,20 @@ BinaryData IPersistableModel.Write(ModelR } } - TestRunStartedNotificationEventFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestRunStartedNotificationEventFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TestRunStartedNotificationEventFilter)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override TestsNotificationEventFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestRunStartedNotificationEventFilter(document.RootElement, options); } default: @@ -105,22 +115,7 @@ TestRunStartedNotificationEventFilter IPersistableModel The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStartedNotificationEventFilter.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStartedNotificationEventFilter.cs index c8e30641e3e7..ee7fa72dc729 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStartedNotificationEventFilter.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStartedNotificationEventFilter.cs @@ -14,15 +14,14 @@ namespace Azure.Developer.LoadTesting public partial class TestRunStartedNotificationEventFilter : TestsNotificationEventFilter { /// Initializes a new instance of . - public TestRunStartedNotificationEventFilter() + public TestRunStartedNotificationEventFilter() : base(NotificationEventType.TestRunStarted) { - 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) + /// Keeps track of any properties unknown to the library. + internal TestRunStartedNotificationEventFilter(NotificationEventType kind, IDictionary additionalBinaryDataProperties) : base(kind, additionalBinaryDataProperties) { } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStatistics.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStatistics.Serialization.cs index 0fe311552cd9..18b559715a0d 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStatistics.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStatistics.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Test run statistics. + public partial class TestRunStatistics : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite /// 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; + string 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); @@ -134,15 +133,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("sentKBytesPerSec"u8); writer.WriteNumberValue(SentKBytesPerSec.Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -151,22 +150,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestRunStatistics IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestRunStatistics IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestRunStatistics JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestRunStatistics DeserializeTestRunStatistics(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -174,237 +178,238 @@ internal static TestRunStatistics DeserializeTestRunStatistics(JsonElement eleme 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? errorPercentage = default; + double? meanResponseTime = default; + double? medianResponseTime = default; + double? maxResponseTime = default; + double? minResponseTime = default; + double? percentile90ResponseTime = default; + double? percentile95ResponseTime = default; + double? percentile99ResponseTime = default; + double? percentile75ResponseTime = default; + double? percentile96ResponseTime = default; + double? percentile97ResponseTime = default; + double? percentile98ResponseTime = default; + double? percentile999ResponseTime = default; + double? percentile9999ResponseTime = default; double? throughput = default; double? receivedKBytesPerSec = default; double? sentKBytesPerSec = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("transaction"u8)) + if (prop.NameEquals("transaction"u8)) { - transaction = property.Value.GetString(); + transaction = prop.Value.GetString(); continue; } - if (property.NameEquals("sampleCount"u8)) + if (prop.NameEquals("sampleCount"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - sampleCount = property.Value.GetDouble(); + sampleCount = prop.Value.GetDouble(); continue; } - if (property.NameEquals("errorCount"u8)) + if (prop.NameEquals("errorCount"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - errorCount = property.Value.GetDouble(); + errorCount = prop.Value.GetDouble(); continue; } - if (property.NameEquals("errorPct"u8)) + if (prop.NameEquals("errorPct"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - errorPct = property.Value.GetDouble(); + errorPercentage = prop.Value.GetDouble(); continue; } - if (property.NameEquals("meanResTime"u8)) + if (prop.NameEquals("meanResTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - meanResTime = property.Value.GetDouble(); + meanResponseTime = prop.Value.GetDouble(); continue; } - if (property.NameEquals("medianResTime"u8)) + if (prop.NameEquals("medianResTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - medianResTime = property.Value.GetDouble(); + medianResponseTime = prop.Value.GetDouble(); continue; } - if (property.NameEquals("maxResTime"u8)) + if (prop.NameEquals("maxResTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - maxResTime = property.Value.GetDouble(); + maxResponseTime = prop.Value.GetDouble(); continue; } - if (property.NameEquals("minResTime"u8)) + if (prop.NameEquals("minResTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - minResTime = property.Value.GetDouble(); + minResponseTime = prop.Value.GetDouble(); continue; } - if (property.NameEquals("pct1ResTime"u8)) + if (prop.NameEquals("pct1ResTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - pct1ResTime = property.Value.GetDouble(); + percentile90ResponseTime = prop.Value.GetDouble(); continue; } - if (property.NameEquals("pct2ResTime"u8)) + if (prop.NameEquals("pct2ResTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - pct2ResTime = property.Value.GetDouble(); + percentile95ResponseTime = prop.Value.GetDouble(); continue; } - if (property.NameEquals("pct3ResTime"u8)) + if (prop.NameEquals("pct3ResTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - pct3ResTime = property.Value.GetDouble(); + percentile99ResponseTime = prop.Value.GetDouble(); continue; } - if (property.NameEquals("pct75ResTime"u8)) + if (prop.NameEquals("pct75ResTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - pct75ResTime = property.Value.GetDouble(); + percentile75ResponseTime = prop.Value.GetDouble(); continue; } - if (property.NameEquals("pct96ResTime"u8)) + if (prop.NameEquals("pct96ResTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - pct96ResTime = property.Value.GetDouble(); + percentile96ResponseTime = prop.Value.GetDouble(); continue; } - if (property.NameEquals("pct97ResTime"u8)) + if (prop.NameEquals("pct97ResTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - pct97ResTime = property.Value.GetDouble(); + percentile97ResponseTime = prop.Value.GetDouble(); continue; } - if (property.NameEquals("pct98ResTime"u8)) + if (prop.NameEquals("pct98ResTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - pct98ResTime = property.Value.GetDouble(); + percentile98ResponseTime = prop.Value.GetDouble(); continue; } - if (property.NameEquals("pct999ResTime"u8)) + if (prop.NameEquals("pct999ResTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - pct999ResTime = property.Value.GetDouble(); + percentile999ResponseTime = prop.Value.GetDouble(); continue; } - if (property.NameEquals("pct9999ResTime"u8)) + if (prop.NameEquals("pct9999ResTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - pct9999ResTime = property.Value.GetDouble(); + percentile9999ResponseTime = prop.Value.GetDouble(); continue; } - if (property.NameEquals("throughput"u8)) + if (prop.NameEquals("throughput"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - throughput = property.Value.GetDouble(); + throughput = prop.Value.GetDouble(); continue; } - if (property.NameEquals("receivedKBytesPerSec"u8)) + if (prop.NameEquals("receivedKBytesPerSec"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - receivedKBytesPerSec = property.Value.GetDouble(); + receivedKBytesPerSec = prop.Value.GetDouble(); continue; } - if (property.NameEquals("sentKBytesPerSec"u8)) + if (prop.NameEquals("sentKBytesPerSec"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - sentKBytesPerSec = property.Value.GetDouble(); + sentKBytesPerSec = prop.Value.GetDouble(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new TestRunStatistics( transaction, sampleCount, errorCount, - errorPct, - meanResTime, - medianResTime, - maxResTime, - minResTime, - pct1ResTime, - pct2ResTime, - pct3ResTime, - pct75ResTime, - pct96ResTime, - pct97ResTime, - pct98ResTime, - pct999ResTime, - pct9999ResTime, + errorPercentage, + meanResponseTime, + medianResponseTime, + maxResponseTime, + minResponseTime, + percentile90ResponseTime, + percentile95ResponseTime, + percentile99ResponseTime, + percentile75ResponseTime, + percentile96ResponseTime, + percentile97ResponseTime, + percentile98ResponseTime, + percentile999ResponseTime, + percentile9999ResponseTime, throughput, receivedKBytesPerSec, sentKBytesPerSec, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -414,15 +419,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o } } - TestRunStatistics IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestRunStatistics IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestRunStatistics PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestRunStatistics(document.RootElement, options); } default: @@ -430,22 +440,7 @@ TestRunStatistics IPersistableModel.Create(BinaryData data, M } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStatistics.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStatistics.cs index 314487a581c8..23079e4a3375 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStatistics.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStatistics.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal TestRunStatistics() @@ -71,8 +42,8 @@ internal TestRunStatistics() /// 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) + /// 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 additionalBinaryDataProperties) { Transaction = transaction; SampleCount = sampleCount; @@ -94,47 +65,66 @@ internal TestRunStatistics(string transaction, double? sampleCount, double? erro Throughput = throughput; ReceivedKBytesPerSec = receivedKBytesPerSec; SentKBytesPerSec = sentKBytesPerSec; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStatus.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStatus.cs index 53ee327572e5..00f8fe5d017d 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStatus.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestRunStatus.cs @@ -14,80 +14,127 @@ namespace Azure.Developer.LoadTesting 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)); - } - + /// Test run request is accepted. private const string AcceptedValue = "ACCEPTED"; + /// Test run is not yet started. private const string NotStartedValue = "NOTSTARTED"; + /// Test run is provisioning. private const string ProvisioningValue = "PROVISIONING"; + /// Test run is provisioned. private const string ProvisionedValue = "PROVISIONED"; + /// Test run is getting configured. private const string ConfiguringValue = "CONFIGURING"; + /// Test run configuration is done. private const string ConfiguredValue = "CONFIGURED"; + /// Test run has started executing. private const string ExecutingValue = "EXECUTING"; + /// Test run execution is completed. private const string ExecutedValue = "EXECUTED"; + /// Test run is getting deprovisioned. private const string DeprovisioningValue = "DEPROVISIONING"; + /// Test run is deprovisioned. private const string DeprovisionedValue = "DEPROVISIONED"; + /// Test run is completed. private const string DoneValue = "DONE"; + /// Test run is being cancelled. private const string CancellingValue = "CANCELLING"; + /// Test run request is cancelled. private const string CancelledValue = "CANCELLED"; + /// Test run request is failed. private const string FailedValue = "FAILED"; + /// Test run JMX file is validated. private const string ValidationSuccessValue = "VALIDATION_SUCCESS"; + /// Test run JMX file validation is failed. private const string ValidationFailureValue = "VALIDATION_FAILURE"; + /// Initializes a new instance of . + /// The value. + /// is null. + public TestRunStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TestRunStatus left, TestRunStatus right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(TestRunStatus left, TestRunStatus right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TestRunStatus(string value) => new TestRunStatus(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TestRunStatus?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestSecret.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestSecret.Serialization.cs index 80eabd523cfc..965695429863 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestSecret.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestSecret.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Secret. + public partial class TestSecret : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +28,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOption /// 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; + string 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); @@ -44,15 +43,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("type"u8); writer.WriteStringValue(SecretKind.Value.ToString()); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,59 +60,65 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestSecret IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestSecret IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestSecret JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestSecret DeserializeTestSecret(JsonElement element, ModelReaderWriterOptions options) { - 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()) + SecretType? secretKind = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { - value = property.Value.GetString(); + value = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - type = new SecretType(property.Value.GetString()); + secretKind = new SecretType(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TestSecret(value, type, serializedAdditionalRawData); + return new TestSecret(value, secretKind, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -123,15 +128,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) } } - TestSecret IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestSecret IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestSecret PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestSecret(document.RootElement, options); } default: @@ -139,22 +149,7 @@ TestSecret IPersistableModel.Create(BinaryData data, ModelReaderWrit } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestSecret.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestSecret.cs index 8e3fdb7897ae..a7f66a07a766 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestSecret.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestSecret.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public TestSecret() @@ -53,16 +24,17 @@ 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) + /// Keeps track of any properties unknown to the library. + internal TestSecret(string value, SecretType? secretKind, IDictionary additionalBinaryDataProperties) { Value = value; SecretKind = secretKind; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestServerMetricsConfiguration.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestServerMetricsConfiguration.Serialization.cs index a04cf1f5d17d..6be8587bc340 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestServerMetricsConfiguration.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestServerMetricsConfiguration.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; namespace Azure.Developer.LoadTesting { - public partial class TestServerMetricsConfiguration : IUtf8JsonSerializable, IJsonModel + /// Test server metrics configuration. + public partial class TestServerMetricsConfiguration : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TestServerMetricsConfiguration() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +34,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mod /// 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; + string 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); @@ -67,15 +72,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("lastModifiedBy"u8); writer.WriteStringValue(LastModifiedBy); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -84,22 +89,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestServerMetricsConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestServerMetricsConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestServerMetricsConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestServerMetricsConfiguration DeserializeTestServerMetricsConfiguration(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -110,59 +120,57 @@ internal static TestServerMetricsConfiguration DeserializeTestServerMetricsConfi string createdBy = default; DateTimeOffset? lastModifiedDateTime = default; string lastModifiedBy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("testId"u8)) + if (prop.NameEquals("testId"u8)) { - testId = property.Value.GetString(); + testId = prop.Value.GetString(); continue; } - if (property.NameEquals("metrics"u8)) + if (prop.NameEquals("metrics"u8)) { Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, ResourceMetric.DeserializeResourceMetric(property0.Value, options)); + dictionary.Add(prop0.Name, ResourceMetric.DeserializeResourceMetric(prop0.Value, options)); } metrics = dictionary; continue; } - if (property.NameEquals("createdDateTime"u8)) + if (prop.NameEquals("createdDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - createdDateTime = property.Value.GetDateTimeOffset("O"); + createdDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("createdBy"u8)) + if (prop.NameEquals("createdBy"u8)) { - createdBy = property.Value.GetString(); + createdBy = prop.Value.GetString(); continue; } - if (property.NameEquals("lastModifiedDateTime"u8)) + if (prop.NameEquals("lastModifiedDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + lastModifiedDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("lastModifiedBy"u8)) + if (prop.NameEquals("lastModifiedBy"u8)) { - lastModifiedBy = property.Value.GetString(); + lastModifiedBy = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new TestServerMetricsConfiguration( testId, metrics, @@ -170,13 +178,16 @@ internal static TestServerMetricsConfiguration DeserializeTestServerMetricsConfi createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -186,15 +197,20 @@ BinaryData IPersistableModel.Write(ModelReaderWr } } - TestServerMetricsConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestServerMetricsConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestServerMetricsConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestServerMetricsConfiguration(document.RootElement, options); } default: @@ -202,22 +218,14 @@ TestServerMetricsConfiguration IPersistableModel } } + /// The client options for reading and writing models. 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() + /// The to deserialize the from. + public static explicit operator TestServerMetricsConfiguration(Response response) { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); - return content; + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestServerMetricsConfiguration(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestServerMetricsConfiguration.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestServerMetricsConfiguration.cs index c36ad8b4f554..3a8e212eaaf4 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestServerMetricsConfiguration.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestServerMetricsConfiguration.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// @@ -70,8 +41,8 @@ public TestServerMetricsConfiguration(IDictionary metric /// 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) + /// Keeps track of any properties unknown to the library. + internal TestServerMetricsConfiguration(string testId, IDictionary metrics, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary additionalBinaryDataProperties) { TestId = testId; Metrics = metrics; @@ -79,28 +50,28 @@ internal TestServerMetricsConfiguration(string testId, IDictionary Initializes a new instance of for deserialization. - internal TestServerMetricsConfiguration() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestsNotificationEventFilter.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestsNotificationEventFilter.Serialization.cs index a96afc50c8e2..39af3dfc305d 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestsNotificationEventFilter.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestsNotificationEventFilter.Serialization.cs @@ -8,15 +8,23 @@ using System; using System.ClientModel.Primitives; using System.Text.Json; -using Azure.Core; namespace Azure.Developer.LoadTesting { + /// + /// The notification event filter for Tests scope. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , and . + /// [PersistableModelProxy(typeof(UnknownTestsNotificationEventFilter))] - public partial class TestsNotificationEventFilter : IUtf8JsonSerializable, IJsonModel + public abstract partial class TestsNotificationEventFilter : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TestsNotificationEventFilter() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,23 +36,22 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model /// 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; + string 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) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -53,43 +60,55 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TestsNotificationEventFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestsNotificationEventFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TestsNotificationEventFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestsNotificationEventFilter DeserializeTestsNotificationEventFilter(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - if (element.TryGetProperty("kind", out JsonElement discriminator)) + if (element.TryGetProperty("kind"u8, 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); + 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; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -99,15 +118,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - TestsNotificationEventFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestsNotificationEventFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TestsNotificationEventFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestsNotificationEventFilter(document.RootElement, options); } default: @@ -115,22 +139,7 @@ TestsNotificationEventFilter IPersistableModel.Cre } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestsNotificationEventFilter.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestsNotificationEventFilter.cs index 1ad444347030..978918982a4c 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestsNotificationEventFilter.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestsNotificationEventFilter.cs @@ -12,55 +12,27 @@ 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 . + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . - protected TestsNotificationEventFilter() + /// The event type. + private protected TestsNotificationEventFilter(NotificationEventType kind) { + Kind = kind; } /// Initializes a new instance of . /// The event type. - /// Keeps track of any properties unknown to the library. - internal TestsNotificationEventFilter(NotificationEventType kind, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TestsNotificationEventFilter(NotificationEventType kind, IDictionary additionalBinaryDataProperties) { Kind = kind; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The event type. diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestsNotificationRule.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestsNotificationRule.Serialization.cs index 14e1a3b62409..a91ecfe6c9cd 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestsNotificationRule.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestsNotificationRule.Serialization.cs @@ -9,14 +9,19 @@ 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 + /// Tests Notification rule model. + public partial class TestsNotificationRule : NotificationRule, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TestsNotificationRule() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,19 +33,23 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW /// 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; + string 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) + foreach (string item in TestIds) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); @@ -55,28 +64,31 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteEndObject(); } - TestsNotificationRule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TestsNotificationRule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TestsNotificationRule)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override NotificationRule JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TestsNotificationRule DeserializeTestsNotificationRule(JsonElement element, ModelReaderWriterOptions options) { - 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; @@ -85,93 +97,107 @@ internal static TestsNotificationRule DeserializeTestsNotificationRule(JsonEleme string createdBy = default; DateTimeOffset? lastModifiedDateTime = default; string lastModifiedBy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList testIds = default; + IDictionary eventFilters = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("testIds"u8)) + if (prop.NameEquals("notificationRuleId"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; + notificationRuleId = prop.Value.GetString(); continue; } - if (property.NameEquals("eventFilters"u8)) + if (prop.NameEquals("displayName"u8)) { - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, TestsNotificationEventFilter.DeserializeTestsNotificationEventFilter(property0.Value, options)); - } - eventFilters = dictionary; + displayName = prop.Value.GetString(); continue; } - if (property.NameEquals("notificationRuleId"u8)) + if (prop.NameEquals("actionGroupIds"u8)) { - notificationRuleId = property.Value.GetString(); + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + actionGroupIds = array; continue; } - if (property.NameEquals("displayName"u8)) + if (prop.NameEquals("scope"u8)) { - displayName = property.Value.GetString(); + scope = new NotificationScopeType(prop.Value.GetString()); continue; } - if (property.NameEquals("actionGroupIds"u8)) + if (prop.NameEquals("createdDateTime"u8)) { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + if (prop.Value.ValueKind == JsonValueKind.Null) { - array.Add(item.GetString()); + continue; } - actionGroupIds = array; + createdDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("scope"u8)) + if (prop.NameEquals("createdBy"u8)) { - scope = new NotificationScopeType(property.Value.GetString()); + createdBy = prop.Value.GetString(); continue; } - if (property.NameEquals("createdDateTime"u8)) + if (prop.NameEquals("lastModifiedDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - createdDateTime = property.Value.GetDateTimeOffset("O"); + lastModifiedDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("createdBy"u8)) + if (prop.NameEquals("lastModifiedBy"u8)) { - createdBy = property.Value.GetString(); + lastModifiedBy = prop.Value.GetString(); continue; } - if (property.NameEquals("lastModifiedDateTime"u8)) + if (prop.NameEquals("testIds"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + testIds = array; continue; } - if (property.NameEquals("lastModifiedBy"u8)) + if (prop.NameEquals("eventFilters"u8)) { - lastModifiedBy = property.Value.GetString(); + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + dictionary.Add(prop0.Name, TestsNotificationEventFilter.DeserializeTestsNotificationEventFilter(prop0.Value, options)); + } + eventFilters = dictionary; continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new TestsNotificationRule( notificationRuleId, displayName, @@ -181,15 +207,18 @@ internal static TestsNotificationRule DeserializeTestsNotificationRule(JsonEleme createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData, + additionalBinaryDataProperties, testIds ?? new ChangeTrackingList(), eventFilters); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -199,15 +228,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - TestsNotificationRule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestsNotificationRule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TestsNotificationRule)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override NotificationRule PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestsNotificationRule(document.RootElement, options); } default: @@ -215,22 +249,7 @@ TestsNotificationRule IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestsNotificationRule.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestsNotificationRule.cs index cb905ac00236..07f419b60db4 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestsNotificationRule.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TestsNotificationRule.cs @@ -19,17 +19,14 @@ public partial class TestsNotificationRule : NotificationRule /// /// 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) + public TestsNotificationRule(string displayName, IEnumerable actionGroupIds, IDictionary eventFilters) : base(displayName, actionGroupIds, NotificationScopeType.Tests) { Argument.AssertNotNull(displayName, nameof(displayName)); Argument.AssertNotNull(actionGroupIds, nameof(actionGroupIds)); Argument.AssertNotNull(eventFilters, nameof(eventFilters)); - Scope = NotificationScopeType.Tests; TestIds = new ChangeTrackingList(); EventFilters = eventFilters; } @@ -43,32 +40,24 @@ public TestsNotificationRule(string displayName, IEnumerable actionGroup /// 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. + /// 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) + internal TestsNotificationRule(string notificationRuleId, string displayName, IList actionGroupIds, NotificationScopeType scope, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary additionalBinaryDataProperties, IList testIds, IDictionary eventFilters) : base(notificationRuleId, displayName, actionGroupIds, scope, createdDateTime, createdBy, lastModifiedDateTime, lastModifiedBy, additionalBinaryDataProperties) { 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TimeGrain.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TimeGrain.cs index 87c543443180..c86913145cbb 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TimeGrain.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TimeGrain.cs @@ -14,47 +14,72 @@ namespace Azure.Developer.LoadTesting public readonly partial struct TimeGrain : IEquatable { private readonly string _value; + /// 5 seconds, available only if test run duration is less than 10 minutes. + private const string FiveSecondsValue = "PT5S"; + /// 10 seconds, available only if test run duration is less than 10 minutes. + private const string TenSecondsValue = "PT10S"; + /// 1 minute. + private const string OneMinuteValue = "PT1M"; + /// 5 minutes, available only if test run duration is greater than 1 minute. + private const string FiveMinutesValue = "PT5M"; + /// 1 hour, available only if test run duration is greater than 1 minute. + private const string OneHourValue = "PT1H"; /// Initializes a new instance of . + /// The value. /// is null. public TimeGrain(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, 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"; + _value = value; + } /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TimeGrain left, TimeGrain right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(TimeGrain left, TimeGrain right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TimeGrain(string value) => new TimeGrain(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TimeGrain?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TimeSeriesElement.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TimeSeriesElement.Serialization.cs index fda4dc5ce855..3e4b28ec6e8b 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TimeSeriesElement.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TimeSeriesElement.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// The time series returned when a data query is performed. + public partial class TimeSeriesElement : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,17 +28,16 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite /// 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; + string 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) + foreach (MetricValue item in Data) { writer.WriteObjectValue(item, options); } @@ -48,21 +47,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("dimensionValues"u8); writer.WriteStartArray(); - foreach (var item in DimensionValues) + foreach (DimensionValue item in DimensionValues) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -71,54 +70,58 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TimeSeriesElement IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TimeSeriesElement IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TimeSeriesElement JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TimeSeriesElement DeserializeTimeSeriesElement(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IList data = default; + IList dimensionValues = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("data"u8)) + if (prop.NameEquals("data"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(MetricValue.DeserializeMetricValue(item, options)); } data = array; continue; } - if (property.NameEquals("dimensionValues"u8)) + if (prop.NameEquals("dimensionValues"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(DimensionValue.DeserializeDimensionValue(item, options)); } @@ -127,17 +130,19 @@ internal static TimeSeriesElement DeserializeTimeSeriesElement(JsonElement eleme } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TimeSeriesElement(data ?? new ChangeTrackingList(), dimensionValues ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new TimeSeriesElement(data ?? new ChangeTrackingList(), dimensionValues ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -147,15 +152,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o } } - TimeSeriesElement IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TimeSeriesElement IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TimeSeriesElement PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTimeSeriesElement(document.RootElement, options); } default: @@ -163,22 +173,7 @@ TimeSeriesElement IPersistableModel.Create(BinaryData data, M } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TimeSeriesElement.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TimeSeriesElement.cs index d8da142d5293..192382f85900 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TimeSeriesElement.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TimeSeriesElement.cs @@ -13,37 +13,8 @@ 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal TimeSeriesElement() @@ -54,18 +25,19 @@ internal TimeSeriesElement() /// 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) + /// The dimension values . + /// Keeps track of any properties unknown to the library. + internal TimeSeriesElement(IList data, IList dimensionValues, IDictionary additionalBinaryDataProperties) { Data = data; DimensionValues = dimensionValues; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// An array of data points representing the metric values. - public IReadOnlyList Data { get; } - /// The dimension values. - public IReadOnlyList DimensionValues { get; } + public IList Data { get; } + + /// The dimension values . + public IList DimensionValues { get; } } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerCompletedNotificationEventFilter.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerCompletedNotificationEventFilter.Serialization.cs index 8b0498f10836..ac58d27a1637 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerCompletedNotificationEventFilter.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerCompletedNotificationEventFilter.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// The notification event filter when the event type is TriggerCompleted. + public partial class TriggerCompletedNotificationEventFilter : TestsNotificationEventFilter, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,58 +28,63 @@ void IJsonModel.Write(Utf8JsonWriter wr /// 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; + string 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) + /// The JSON reader. + /// The client options for reading and writing models. + TriggerCompletedNotificationEventFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TriggerCompletedNotificationEventFilter)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TestsNotificationEventFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TriggerCompletedNotificationEventFilter DeserializeTriggerCompletedNotificationEventFilter(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("kind"u8)) + if (prop.NameEquals("kind"u8)) { - kind = new NotificationEventType(property.Value.GetString()); + kind = new NotificationEventType(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TriggerCompletedNotificationEventFilter(kind, serializedAdditionalRawData); + return new TriggerCompletedNotificationEventFilter(kind, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -89,15 +94,20 @@ BinaryData IPersistableModel.Write(Mode } } - TriggerCompletedNotificationEventFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TriggerCompletedNotificationEventFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TriggerCompletedNotificationEventFilter)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override TestsNotificationEventFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTriggerCompletedNotificationEventFilter(document.RootElement, options); } default: @@ -105,22 +115,7 @@ TriggerCompletedNotificationEventFilter IPersistableModel The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerCompletedNotificationEventFilter.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerCompletedNotificationEventFilter.cs index 110c5e185031..129ff70ee8e4 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerCompletedNotificationEventFilter.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerCompletedNotificationEventFilter.cs @@ -14,15 +14,14 @@ namespace Azure.Developer.LoadTesting public partial class TriggerCompletedNotificationEventFilter : TestsNotificationEventFilter { /// Initializes a new instance of . - public TriggerCompletedNotificationEventFilter() + public TriggerCompletedNotificationEventFilter() : base(NotificationEventType.TriggerCompleted) { - 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) + /// Keeps track of any properties unknown to the library. + internal TriggerCompletedNotificationEventFilter(NotificationEventType kind, IDictionary additionalBinaryDataProperties) : base(kind, additionalBinaryDataProperties) { } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerDisabledNotificationEventFilter.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerDisabledNotificationEventFilter.Serialization.cs index eb7176413cd6..7a5d2bc6d4e3 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerDisabledNotificationEventFilter.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerDisabledNotificationEventFilter.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// The notification event filter when the event type is TriggerDisabled. + public partial class TriggerDisabledNotificationEventFilter : TestsNotificationEventFilter, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,58 +28,63 @@ void IJsonModel.Write(Utf8JsonWriter wri /// 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; + string 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) + /// The JSON reader. + /// The client options for reading and writing models. + TriggerDisabledNotificationEventFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TriggerDisabledNotificationEventFilter)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TestsNotificationEventFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TriggerDisabledNotificationEventFilter DeserializeTriggerDisabledNotificationEventFilter(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("kind"u8)) + if (prop.NameEquals("kind"u8)) { - kind = new NotificationEventType(property.Value.GetString()); + kind = new NotificationEventType(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TriggerDisabledNotificationEventFilter(kind, serializedAdditionalRawData); + return new TriggerDisabledNotificationEventFilter(kind, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -89,15 +94,20 @@ BinaryData IPersistableModel.Write(Model } } - TriggerDisabledNotificationEventFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TriggerDisabledNotificationEventFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TriggerDisabledNotificationEventFilter)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override TestsNotificationEventFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTriggerDisabledNotificationEventFilter(document.RootElement, options); } default: @@ -105,22 +115,7 @@ TriggerDisabledNotificationEventFilter IPersistableModel The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerDisabledNotificationEventFilter.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerDisabledNotificationEventFilter.cs index 32b3e34810a9..ad580a3311e0 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerDisabledNotificationEventFilter.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerDisabledNotificationEventFilter.cs @@ -14,15 +14,14 @@ namespace Azure.Developer.LoadTesting public partial class TriggerDisabledNotificationEventFilter : TestsNotificationEventFilter { /// Initializes a new instance of . - public TriggerDisabledNotificationEventFilter() + public TriggerDisabledNotificationEventFilter() : base(NotificationEventType.TriggerDisabled) { - 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) + /// Keeps track of any properties unknown to the library. + internal TriggerDisabledNotificationEventFilter(NotificationEventType kind, IDictionary additionalBinaryDataProperties) : base(kind, additionalBinaryDataProperties) { } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerState.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerState.cs index 5bece83171ef..63ee95ad06b6 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerState.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerState.cs @@ -14,44 +14,67 @@ namespace Azure.Developer.LoadTesting public readonly partial struct TriggerState : IEquatable { private readonly string _value; + /// The trigger is active. + private const string ActiveValue = "Active"; + /// The trigger is paused manually. + private const string PausedValue = "Paused"; + /// The trigger is completed. + private const string CompletedValue = "Completed"; + /// The trigger is disabled due to error. + private const string DisabledValue = "Disabled"; /// Initializes a new instance of . + /// The value. /// is null. public TriggerState(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string ActiveValue = "Active"; - private const string PausedValue = "Paused"; - private const string CompletedValue = "Completed"; - private const string DisabledValue = "Disabled"; + _value = value; + } /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TriggerState left, TriggerState right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(TriggerState left, TriggerState right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TriggerState(string value) => new TriggerState(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TriggerState?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerType.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerType.cs index a39a1e5d0b1e..8f29854d62ec 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerType.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/TriggerType.cs @@ -14,35 +14,52 @@ namespace Azure.Developer.LoadTesting internal readonly partial struct TriggerType : IEquatable { private readonly string _value; + /// Trigger is a Scheduled Trigger on a Test. + private const string ScheduleTestsTriggerValue = "ScheduleTestsTrigger"; /// Initializes a new instance of . + /// The value. /// is null. public TriggerType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string ScheduleTestsTriggerValue = "ScheduleTestsTrigger"; + _value = value; + } /// Trigger is a Scheduled Trigger on a Test. public static TriggerType ScheduleTestsTrigger { get; } = new TriggerType(ScheduleTestsTriggerValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TriggerType left, TriggerType right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(TriggerType left, TriggerType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TriggerType(string value) => new TriggerType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TriggerType?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownLoadTestingRecurrence.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownLoadTestingRecurrence.Serialization.cs index 32a524a3811c..a8f8242c6835 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownLoadTestingRecurrence.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownLoadTestingRecurrence.Serialization.cs @@ -9,14 +9,18 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; namespace Azure.Developer.LoadTesting { - internal partial class UnknownLoadTestingRecurrence : IUtf8JsonSerializable, IJsonModel + internal partial class UnknownLoadTestingRecurrence : LoadTestingRecurrence, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal UnknownLoadTestingRecurrence() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,68 +32,73 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(LoadTestingRecurrence)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); } - LoadTestingRecurrence IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + LoadTestingRecurrence IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override LoadTestingRecurrence JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(LoadTestingRecurrence)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeLoadTestingRecurrence(document.RootElement, options); } - internal static UnknownLoadTestingRecurrence DeserializeUnknownLoadTestingRecurrence(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownLoadTestingRecurrence DeserializeUnknownLoadTestingRecurrence(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - Frequency frequency = "Unknown"; + Frequency frequency = default; RecurrenceEnd recurrenceEnd = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("frequency"u8)) + if (prop.NameEquals("frequency"u8)) { - frequency = new Frequency(property.Value.GetString()); + frequency = new Frequency(prop.Value.GetString()); continue; } - if (property.NameEquals("recurrenceEnd"u8)) + if (prop.NameEquals("recurrenceEnd"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(property.Value, options); + recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownLoadTestingRecurrence(frequency, recurrenceEnd, serializedAdditionalRawData); + return new UnknownLoadTestingRecurrence(frequency, recurrenceEnd, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -99,15 +108,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - LoadTestingRecurrence IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + LoadTestingRecurrence IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override LoadTestingRecurrence PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeLoadTestingRecurrence(document.RootElement, options); } default: @@ -115,22 +129,7 @@ LoadTestingRecurrence IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The response to deserialize the model from. - internal static new UnknownLoadTestingRecurrence FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownLoadTestingRecurrence(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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownLoadTestingRecurrence.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownLoadTestingRecurrence.cs index 407e221aa211..0e6e97b1036c 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownLoadTestingRecurrence.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownLoadTestingRecurrence.cs @@ -10,19 +10,13 @@ namespace Azure.Developer.LoadTesting { - /// Unknown version of LoadTestingRecurrence. internal partial class UnknownLoadTestingRecurrence : LoadTestingRecurrence { /// 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 UnknownLoadTestingRecurrence(Frequency frequency, RecurrenceEnd recurrenceEnd, IDictionary serializedAdditionalRawData) : base(frequency, recurrenceEnd, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal UnknownLoadTestingRecurrence() + /// Keeps track of any properties unknown to the library. + internal UnknownLoadTestingRecurrence(Frequency frequency, RecurrenceEnd recurrenceEnd, IDictionary additionalBinaryDataProperties) : base(frequency != default ? frequency : "unknown", recurrenceEnd, additionalBinaryDataProperties) { } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownLoadTestingTrigger.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownLoadTestingTrigger.Serialization.cs index dfa38b97cb7c..db442fa6f095 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownLoadTestingTrigger.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownLoadTestingTrigger.Serialization.cs @@ -9,14 +9,18 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; namespace Azure.Developer.LoadTesting { - internal partial class UnknownLoadTestingTrigger : IUtf8JsonSerializable, IJsonModel + internal partial class UnknownLoadTestingTrigger : LoadTestingTrigger, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal UnknownLoadTestingTrigger() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,31 +32,35 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(LoadTestingTrigger)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); } - LoadTestingTrigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + LoadTestingTrigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override LoadTestingTrigger JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(LoadTestingTrigger)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeLoadTestingTrigger(document.RootElement, options); } - internal static UnknownLoadTestingTrigger DeserializeUnknownLoadTestingTrigger(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownLoadTestingTrigger DeserializeUnknownLoadTestingTrigger(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -60,89 +68,87 @@ internal static UnknownLoadTestingTrigger DeserializeUnknownLoadTestingTrigger(J string triggerId = default; string displayName = default; string description = default; - TriggerType kind = "Unknown"; + 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("triggerId"u8)) + if (prop.NameEquals("triggerId"u8)) { - triggerId = property.Value.GetString(); + triggerId = prop.Value.GetString(); continue; } - if (property.NameEquals("displayName"u8)) + if (prop.NameEquals("displayName"u8)) { - displayName = property.Value.GetString(); + displayName = prop.Value.GetString(); continue; } - if (property.NameEquals("description"u8)) + if (prop.NameEquals("description"u8)) { - description = property.Value.GetString(); + description = prop.Value.GetString(); continue; } - if (property.NameEquals("kind"u8)) + if (prop.NameEquals("kind"u8)) { - kind = new TriggerType(property.Value.GetString()); + kind = new TriggerType(prop.Value.GetString()); continue; } - if (property.NameEquals("state"u8)) + if (prop.NameEquals("state"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - state = new TriggerState(property.Value.GetString()); + state = new TriggerState(prop.Value.GetString()); continue; } - if (property.NameEquals("stateDetails"u8)) + if (prop.NameEquals("stateDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - stateDetails = StateDetails.DeserializeStateDetails(property.Value, options); + stateDetails = StateDetails.DeserializeStateDetails(prop.Value, options); continue; } - if (property.NameEquals("createdDateTime"u8)) + if (prop.NameEquals("createdDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - createdDateTime = property.Value.GetDateTimeOffset("O"); + createdDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("createdBy"u8)) + if (prop.NameEquals("createdBy"u8)) { - createdBy = property.Value.GetString(); + createdBy = prop.Value.GetString(); continue; } - if (property.NameEquals("lastModifiedDateTime"u8)) + if (prop.NameEquals("lastModifiedDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + lastModifiedDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("lastModifiedBy"u8)) + if (prop.NameEquals("lastModifiedBy"u8)) { - lastModifiedBy = property.Value.GetString(); + lastModifiedBy = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new UnknownLoadTestingTrigger( triggerId, displayName, @@ -154,13 +160,16 @@ internal static UnknownLoadTestingTrigger DeserializeUnknownLoadTestingTrigger(J createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -170,15 +179,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - LoadTestingTrigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + LoadTestingTrigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override LoadTestingTrigger PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeLoadTestingTrigger(document.RootElement, options); } default: @@ -186,22 +200,7 @@ LoadTestingTrigger IPersistableModel.Create(BinaryData data, } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The response to deserialize the model from. - internal static new UnknownLoadTestingTrigger FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeUnknownLoadTestingTrigger(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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownLoadTestingTrigger.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownLoadTestingTrigger.cs index f9948fb346e3..04f4f181fe36 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownLoadTestingTrigger.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownLoadTestingTrigger.cs @@ -10,7 +10,6 @@ namespace Azure.Developer.LoadTesting { - /// Unknown version of LoadTestingTrigger. internal partial class UnknownLoadTestingTrigger : LoadTestingTrigger { /// Initializes a new instance of . @@ -24,13 +23,8 @@ internal partial class UnknownLoadTestingTrigger : LoadTestingTrigger /// 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 UnknownLoadTestingTrigger(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 UnknownLoadTestingTrigger() + /// Keeps track of any properties unknown to the library. + internal UnknownLoadTestingTrigger(string triggerId, string displayName, string description, TriggerType kind, TriggerState? state, StateDetails stateDetails, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary additionalBinaryDataProperties) : base(triggerId, displayName, description, kind != default ? kind : "unknown", state, stateDetails, createdDateTime, createdBy, lastModifiedDateTime, lastModifiedBy, additionalBinaryDataProperties) { } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownNotificationRule.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownNotificationRule.Serialization.cs index 77a0a4d44b4e..7348a4864419 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownNotificationRule.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownNotificationRule.Serialization.cs @@ -9,14 +9,18 @@ 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 + internal partial class UnknownNotificationRule : NotificationRule, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal UnknownNotificationRule() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,31 +32,35 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter /// 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; + string 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) + /// The JSON reader. + /// The client options for reading and writing models. + NotificationRule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override NotificationRule JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownNotificationRule DeserializeUnknownNotificationRule(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -60,74 +68,79 @@ internal static UnknownNotificationRule DeserializeUnknownNotificationRule(JsonE string notificationRuleId = default; string displayName = default; IList actionGroupIds = default; - NotificationScopeType scope = "Unknown"; + 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("notificationRuleId"u8)) + if (prop.NameEquals("notificationRuleId"u8)) { - notificationRuleId = property.Value.GetString(); + notificationRuleId = prop.Value.GetString(); continue; } - if (property.NameEquals("displayName"u8)) + if (prop.NameEquals("displayName"u8)) { - displayName = property.Value.GetString(); + displayName = prop.Value.GetString(); continue; } - if (property.NameEquals("actionGroupIds"u8)) + if (prop.NameEquals("actionGroupIds"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { - array.Add(item.GetString()); + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } } actionGroupIds = array; continue; } - if (property.NameEquals("scope"u8)) + if (prop.NameEquals("scope"u8)) { - scope = new NotificationScopeType(property.Value.GetString()); + scope = new NotificationScopeType(prop.Value.GetString()); continue; } - if (property.NameEquals("createdDateTime"u8)) + if (prop.NameEquals("createdDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - createdDateTime = property.Value.GetDateTimeOffset("O"); + createdDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("createdBy"u8)) + if (prop.NameEquals("createdBy"u8)) { - createdBy = property.Value.GetString(); + createdBy = prop.Value.GetString(); continue; } - if (property.NameEquals("lastModifiedDateTime"u8)) + if (prop.NameEquals("lastModifiedDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + lastModifiedDateTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("lastModifiedBy"u8)) + if (prop.NameEquals("lastModifiedBy"u8)) { - lastModifiedBy = property.Value.GetString(); + lastModifiedBy = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new UnknownNotificationRule( notificationRuleId, displayName, @@ -137,13 +150,16 @@ internal static UnknownNotificationRule DeserializeUnknownNotificationRule(JsonE createdBy, lastModifiedDateTime, lastModifiedBy, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -153,15 +169,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions op } } - NotificationRule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + NotificationRule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override NotificationRule PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeNotificationRule(document.RootElement, options); } default: @@ -169,22 +190,7 @@ NotificationRule IPersistableModel.Create(BinaryData data, Mod } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownNotificationRule.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownNotificationRule.cs index b89ffa8fec31..24e24088026c 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownNotificationRule.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownNotificationRule.cs @@ -10,7 +10,6 @@ namespace Azure.Developer.LoadTesting { - /// Unknown version of NotificationRule. internal partial class UnknownNotificationRule : NotificationRule { /// Initializes a new instance of . @@ -22,13 +21,8 @@ internal partial class UnknownNotificationRule : NotificationRule /// 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() + /// 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 additionalBinaryDataProperties) : base(notificationRuleId, displayName, actionGroupIds, scope != default ? scope : "unknown", createdDateTime, createdBy, lastModifiedDateTime, lastModifiedBy, additionalBinaryDataProperties) { } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownTargetResourceConfigurations.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownTargetResourceConfigurations.Serialization.cs index 0482805557e4..053d12fab908 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownTargetResourceConfigurations.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownTargetResourceConfigurations.Serialization.cs @@ -9,14 +9,18 @@ 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 + internal partial class UnknownTargetResourceConfigurations : TargetResourceConfigurations, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal UnknownTargetResourceConfigurations() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,58 +32,63 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model /// 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; + string 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) + /// The JSON reader. + /// The client options for reading and writing models. + TargetResourceConfigurations IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TargetResourceConfigurations JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownTargetResourceConfigurations DeserializeUnknownTargetResourceConfigurations(JsonElement element, ModelReaderWriterOptions options) { - 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()) + ResourceKind kind = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("kind"u8)) + if (prop.NameEquals("kind"u8)) { - kind = new ResourceKind(property.Value.GetString()); + kind = new ResourceKind(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownTargetResourceConfigurations(kind, serializedAdditionalRawData); + return new UnknownTargetResourceConfigurations(kind, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -89,15 +98,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - TargetResourceConfigurations IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TargetResourceConfigurations IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override TargetResourceConfigurations PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTargetResourceConfigurations(document.RootElement, options); } default: @@ -105,22 +119,7 @@ TargetResourceConfigurations IPersistableModel.Cre } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownTargetResourceConfigurations.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownTargetResourceConfigurations.cs index b9bbc8047dc9..8cd2c9332cf4 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownTargetResourceConfigurations.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownTargetResourceConfigurations.cs @@ -10,18 +10,12 @@ 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() + /// Keeps track of any properties unknown to the library. + internal UnknownTargetResourceConfigurations(ResourceKind kind, IDictionary additionalBinaryDataProperties) : base(kind != default ? kind : "unknown", additionalBinaryDataProperties) { } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownTestsNotificationEventFilter.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownTestsNotificationEventFilter.Serialization.cs index cdcc0ab271e7..8872a56dadec 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownTestsNotificationEventFilter.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownTestsNotificationEventFilter.Serialization.cs @@ -9,14 +9,18 @@ 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 + internal partial class UnknownTestsNotificationEventFilter : TestsNotificationEventFilter, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal UnknownTestsNotificationEventFilter() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,58 +32,63 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model /// 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; + string 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) + /// The JSON reader. + /// The client options for reading and writing models. + TestsNotificationEventFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TestsNotificationEventFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownTestsNotificationEventFilter DeserializeUnknownTestsNotificationEventFilter(JsonElement element, ModelReaderWriterOptions options) { - 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()) + NotificationEventType kind = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("kind"u8)) + if (prop.NameEquals("kind"u8)) { - kind = new NotificationEventType(property.Value.GetString()); + kind = new NotificationEventType(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownTestsNotificationEventFilter(kind, serializedAdditionalRawData); + return new UnknownTestsNotificationEventFilter(kind, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -89,15 +98,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - TestsNotificationEventFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TestsNotificationEventFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override TestsNotificationEventFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTestsNotificationEventFilter(document.RootElement, options); } default: @@ -105,22 +119,7 @@ TestsNotificationEventFilter IPersistableModel.Cre } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownTestsNotificationEventFilter.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownTestsNotificationEventFilter.cs index 901ee52818b8..719c4adf4067 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownTestsNotificationEventFilter.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/UnknownTestsNotificationEventFilter.cs @@ -10,18 +10,12 @@ 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() + /// Keeps track of any properties unknown to the library. + internal UnknownTestsNotificationEventFilter(NotificationEventType kind, IDictionary additionalBinaryDataProperties) : base(kind != default ? kind : "unknown", additionalBinaryDataProperties) { } } diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/WeekDays.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/WeekDays.cs index d32f662ec839..254b0b9c6d2a 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/WeekDays.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/WeekDays.cs @@ -14,53 +14,82 @@ namespace Azure.Developer.LoadTesting 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)); - } - + /// Refers to Sunday. private const string SundayValue = "Sunday"; + /// Refers to Monday. private const string MondayValue = "Monday"; + /// Refers to Tuesday. private const string TuesdayValue = "Tuesday"; + /// Refers to Wednesday. private const string WednesdayValue = "Wednesday"; + /// Refers to Thursday. private const string ThursdayValue = "Thursday"; + /// Refers to Friday. private const string FridayValue = "Friday"; + /// Refers to Saturday. private const string SaturdayValue = "Saturday"; + /// Initializes a new instance of . + /// The value. + /// is null. + public WeekDays(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + /// 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. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(WeekDays left, WeekDays right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(WeekDays left, WeekDays right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator WeekDays(string value) => new WeekDays(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator WeekDays?(string value) => value == null ? null : 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/WeeklyRecurrence.Serialization.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/WeeklyRecurrence.Serialization.cs index 69023e478268..a6e75d8503e5 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/WeeklyRecurrence.Serialization.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/WeeklyRecurrence.Serialization.cs @@ -9,14 +9,14 @@ 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 + /// Recurrence model when frequency is set as weekly. + public partial class WeeklyRecurrence : LoadTestingRecurrence, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,18 +28,17 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter /// 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; + string 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) + foreach (WeekDays item in DaysOfWeek) { writer.WriteStringValue(item.ToString()); } @@ -52,84 +51,90 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - WeeklyRecurrence IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + WeeklyRecurrence IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (WeeklyRecurrence)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override LoadTestingRecurrence JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string 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) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static WeeklyRecurrence DeserializeWeeklyRecurrence(JsonElement element, ModelReaderWriterOptions options) { - 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()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList daysOfWeek = default; + int? interval = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("daysOfWeek"u8)) + if (prop.NameEquals("frequency"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; + frequency = new Frequency(prop.Value.GetString()); continue; } - if (property.NameEquals("interval"u8)) + if (prop.NameEquals("recurrenceEnd"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - interval = property.Value.GetInt32(); + recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(prop.Value, options); continue; } - if (property.NameEquals("frequency"u8)) + if (prop.NameEquals("daysOfWeek"u8)) { - frequency = new Frequency(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(new WeekDays(item.GetString())); + } + daysOfWeek = array; continue; } - if (property.NameEquals("recurrenceEnd"u8)) + if (prop.NameEquals("interval"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - recurrenceEnd = RecurrenceEnd.DeserializeRecurrenceEnd(property.Value, options); + interval = prop.Value.GetInt32(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new WeeklyRecurrence(frequency, recurrenceEnd, serializedAdditionalRawData, daysOfWeek ?? new ChangeTrackingList(), interval); + return new WeeklyRecurrence(frequency, recurrenceEnd, additionalBinaryDataProperties, daysOfWeek ?? new ChangeTrackingList(), interval); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -139,15 +144,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions op } } - WeeklyRecurrence IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + WeeklyRecurrence IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (WeeklyRecurrence)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override LoadTestingRecurrence PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeWeeklyRecurrence(document.RootElement, options); } default: @@ -155,22 +165,7 @@ WeeklyRecurrence IPersistableModel.Create(BinaryData data, Mod } } + /// The client options for reading and writing models. 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/loadtestservice/Azure.Developer.LoadTesting/src/Generated/WeeklyRecurrence.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/WeeklyRecurrence.cs index db05460d980e..6bcae30754ef 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/WeeklyRecurrence.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/Generated/WeeklyRecurrence.cs @@ -14,19 +14,18 @@ namespace Azure.Developer.LoadTesting public partial class WeeklyRecurrence : LoadTestingRecurrence { /// Initializes a new instance of . - public WeeklyRecurrence() + public WeeklyRecurrence() : base(Frequency.Weekly) { - 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. + /// 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) + internal WeeklyRecurrence(Frequency frequency, RecurrenceEnd recurrenceEnd, IDictionary additionalBinaryDataProperties, IList daysOfWeek, int? interval) : base(frequency, recurrenceEnd, additionalBinaryDataProperties) { DaysOfWeek = daysOfWeek; Interval = interval; @@ -34,6 +33,7 @@ internal WeeklyRecurrence(Frequency frequency, RecurrenceEnd recurrenceEnd, IDic /// 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/loadtestservice/Azure.Developer.LoadTesting/src/LoadTestAdministrationClient.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/LoadTestAdministrationClient.cs deleted file mode 100644 index 2927eb703b21..000000000000 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/LoadTestAdministrationClient.cs +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Autorest.CSharp.Core; -using Azure.Core; - -namespace Azure.Developer.LoadTesting -{ - public partial class LoadTestAdministrationClient - { - /// Upload input file for a given test name. 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. - /// Defines how to use the LRO, if passed WaitUntil.Completed then waits for complete file validation - /// 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. Details of the request body schema are in the Remarks section below. - /// pollingInterval for poller class, default value or null value is treated as 5 secs - /// File type. Allowed values: "JMX_FILE" | "USER_PROPERTIES" | "ADDITIONAL_ARTIFACTS". - /// 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. Details of the response body schema are in the Remarks section below. - public virtual FileUploadResultOperation UploadTestFile(WaitUntil waitUntil, string testId, string fileName, RequestContent content, TimeSpan? timeSpan = null, 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(); - - if (timeSpan == null) - { - timeSpan = TimeSpan.FromSeconds(5); - } - - try - { - Response initialResponse = UploadTestFile(testId, fileName, content, fileType, context); - FileUploadResultOperation operation = new(testId, fileName, this, initialResponse); - if (waitUntil == WaitUntil.Completed) - { - operation.WaitForCompletion((TimeSpan)timeSpan, cancellationToken: default); - } - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Upload input file for a given test name. 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. - /// Defines how to use the LRO, if passed WaitUntil.Completed then waits for complete file validation - /// 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. Details of the request body schema are in the Remarks section below. - /// pollingInterval for poller class, default value or null value is treated as 5 secs - /// File type. Allowed values: "JMX_FILE" | "USER_PROPERTIES" | "ADDITIONAL_ARTIFACTS". - /// 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. Details of the response body schema are in the Remarks section below. - public virtual async Task UploadTestFileAsync(WaitUntil waitUntil, string testId, string fileName, RequestContent content, TimeSpan? timeSpan = null, 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(); - - if (timeSpan == null) - { - timeSpan = TimeSpan.FromSeconds(5); - } - - try - { - Response initialResponse = await UploadTestFileAsync(testId, fileName, content, fileType, context).ConfigureAwait(false); - FileUploadResultOperation operation = new(testId, fileName, this, initialResponse); - if (waitUntil == WaitUntil.Completed) - { - await operation.WaitForCompletionAsync((TimeSpan)timeSpan, cancellationToken: default).ConfigureAwait(false); - } - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// 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(ISO 8601 literal format) of the last updated time range to filter tests. - /// End DateTime(ISO 8601 literal format) of the last updated time range to filter tests. - /// 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, 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 PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTests", "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(ISO 8601 literal format) of the last updated time range to filter tests. - /// End DateTime(ISO 8601 literal format) of the last updated time range to filter tests. - /// 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, 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 PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTests", "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. - /// The cancellation token to use. - public virtual AsyncPageable GetTestsAsync(string orderby = null, string search = null, DateTimeOffset? lastModifiedStartTime = null, DateTimeOffset? lastModifiedEndTime = 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", 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. - /// The cancellation token to use. - public virtual Pageable GetTests(string orderby = null, string search = null, DateTimeOffset? lastModifiedStartTime = null, DateTimeOffset? lastModifiedEndTime = 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", context); - } - - /// List test profiles. - /// 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(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", context); - } - - /// List test profiles. - /// 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(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", 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. - /// - /// - /// - /// - /// 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(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", 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. - /// - /// - /// - /// - /// 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(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", context); - } - } -} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/LoadTestRunClient.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/LoadTestRunClient.cs deleted file mode 100644 index 079cabd40f19..000000000000 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/LoadTestRunClient.cs +++ /dev/null @@ -1,434 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Threading; -using System.Threading.Tasks; -using Autorest.CSharp.Core; -using Azure.Core; - -namespace Azure.Developer.LoadTesting -{ - public partial class LoadTestRunClient - { - /// Create and start a new test run with the given name. - /// Defines how to use the LRO, if passed WaitUntil.Completed then waits for test run to get completed - /// Unique name 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. Details of the request body schema are in the Remarks section below. - /// pollingInterval for poller class, default value or null value is treated as 5 secs - /// 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. Details of the response body schema are in the Remarks section below. - public virtual TestRunResultOperation BeginTestRun(WaitUntil waitUntil, string testRunId, RequestContent content, TimeSpan? timeSpan = null, string oldTestRunId = null, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.BeginTestRun"); - scope.Start(); - - if (timeSpan == null) - { - timeSpan = TimeSpan.FromSeconds(5); - } - - try - { - Response initialResponse = CreateOrUpdateTestRun(testRunId, content, oldTestRunId, context); - TestRunResultOperation operation = new(testRunId, this, initialResponse); - if (waitUntil == WaitUntil.Completed) - { - operation.WaitForCompletion((TimeSpan)timeSpan, cancellationToken: default); - } - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Create and start a new test run with the given name. - /// Unique name 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. Details of the request body schema are in the Remarks section below. - /// Defines how to use the LRO, if passed WaitUntil.Completed then waits for test run to get completed - /// pollingInterval for poller class, default value or null value is treated as 5 secs - /// 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. Details of the response body schema are in the Remarks section below. - public virtual async Task BeginTestRunAsync(WaitUntil waitUntil, string testRunId, RequestContent content, TimeSpan? timeSpan = null, string oldTestRunId = null, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.BeginTestRun"); - scope.Start(); - - if (timeSpan == null) - { - timeSpan = TimeSpan.FromSeconds(5); - } - - try - { - Response initialResponse = await CreateOrUpdateTestRunAsync(testRunId, content, oldTestRunId, context).ConfigureAwait(false); - TestRunResultOperation operation = new(testRunId, this, initialResponse); - if (waitUntil == WaitUntil.Completed) - { - await operation.WaitForCompletionAsync((TimeSpan)timeSpan, cancellationToken: default).ConfigureAwait(false); - } - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Create and start a new test profile run with the given name. - /// Defines how to use the LRO, if passed WaitUntil.Completed then waits for test profile run to get completed - /// Unique name 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. Details of the request body schema are in the Remarks section below. - /// pollingInterval for poller class, default value or null value is treated as 5 secs - /// 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. Details of the response body schema are in the Remarks section below. - public virtual Operation BeginTestProfileRun(WaitUntil waitUntil, string testProfileRunId, RequestContent content, TimeSpan? timeSpan = null, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.BeginTestProfileRun"); - scope.Start(); - - if (timeSpan == null) - { - timeSpan = TimeSpan.FromSeconds(5); - } - - try - { - Response initialResponse = CreateOrUpdateTestProfileRun(testProfileRunId, content, context); - TestProfileRunResultOperation operation = new(testProfileRunId, this, initialResponse); - if (waitUntil == WaitUntil.Completed) - { - operation.WaitForCompletion((TimeSpan)timeSpan, cancellationToken: default); - } - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Create and start a new test profile run with the given name. - /// Defines how to use the LRO, if passed WaitUntil.Completed then waits for test profile run to get completed - /// Unique name 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. Details of the request body schema are in the Remarks section below. - /// pollingInterval for poller class, default value or null value is treated as 5 secs - /// 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. Details of the response body schema are in the Remarks section below. - public virtual async Task> BeginTestProfileRunAsync(WaitUntil waitUntil, string testProfileRunId, RequestContent content, TimeSpan? timeSpan = null, RequestContext context = null) - { - Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.BeginTestProfileRun"); - scope.Start(); - - if (timeSpan == null) - { - timeSpan = TimeSpan.FromSeconds(5); - } - - try - { - Response initialResponse = await CreateOrUpdateTestProfileRunAsync(testProfileRunId, content, context).ConfigureAwait(false); - TestProfileRunResultOperation operation = new(testProfileRunId, this, initialResponse); - if (waitUntil == WaitUntil.Completed) - { - operation.WaitForCompletion((TimeSpan)timeSpan, cancellationToken: default); - } - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Get all test runs with 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(ISO 8601 literal format) of test-run execution time filter range. - /// End DateTime(ISO 8601 literal format) of test-run execution time filter range. - /// Comma separated list of test run status. - /// 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. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual AsyncPageable GetTestRunsAsync(string orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, RequestContext context) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestRunsRequest(orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, null, null, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestRunsNextPageRequest(nextLink, orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, null, null, context); - return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestRuns", "value", "nextLink", context); - } - - /// Get all test runs with 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(ISO 8601 literal format) of test-run execution time filter range. - /// End DateTime(ISO 8601 literal format) of test-run execution time filter range. - /// Comma separated list of test run status. - /// 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. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual Pageable GetTestRuns(string orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, RequestContext context) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestRunsRequest(orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, null, null, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestRunsNextPageRequest(nextLink, orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, null, null, context); - return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestRuns", "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. - /// The cancellation token to use. -#pragma warning disable AZC0002 - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual AsyncPageable GetTestRunsAsync(string orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, CancellationToken cancellationToken) -#pragma warning restore AZC0002 - { - RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestRunsRequest(orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, null, null, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestRunsNextPageRequest(nextLink, orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, null, null, context); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => LoadTestRun.DeserializeLoadTestRun(e), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestRuns", "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. - /// The cancellation token to use. -#pragma warning disable AZC0002 - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual Pageable GetTestRuns(string orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, CancellationToken cancellationToken) -#pragma warning restore AZC0002 - { - RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; - HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestRunsRequest(orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, null, null, context); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestRunsNextPageRequest(nextLink, orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, null, null, context); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => LoadTestRun.DeserializeLoadTestRun(e), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestRuns", "value", "nextLink", context); - } - - /// List test profile runs. - /// 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(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", context); - } - - /// List test profile runs. - /// 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(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", 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. - /// - /// - /// - /// - /// 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(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", 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. - /// - /// - /// - /// - /// 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(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", 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'. - /// The content to send as the body of the request. Details of the request body schema are in the Remarks section below. - /// 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, string interval, RequestContext context) - { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - Argument.AssertNotNull(metricName, nameof(metricName)); - Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); - Argument.AssertNotNull(timespan, nameof(timespan)); - - if (content == null) - { - content = RequestContent.Create(new { }); - } - - 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 PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), 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'. - /// The content to send as the body of the request. Details of the request body schema are in the Remarks section below. - /// 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, string interval, RequestContext context) - { - Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); - Argument.AssertNotNull(metricName, nameof(metricName)); - Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); - Argument.AssertNotNull(timespan, nameof(timespan)); - - if (content == null) - { - content = RequestContent.Create(new { }); - } - - 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 PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetMetrics", "value", "nextLink", context); - } - } -} diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/tsp-location.yaml b/sdk/loadtestservice/Azure.Developer.LoadTesting/tsp-location.yaml index afad912399d5..61c5d366a09c 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/tsp-location.yaml +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/tsp-location.yaml @@ -1,3 +1,4 @@ directory: specification/loadtestservice/data-plane/loadtesting commit: f554f482e7a24b1ec057897865e106648e7b2ce7 repo: Azure/azure-rest-api-specs +emitterPackageJsonPath: eng/azure-typespec-http-client-csharp-emitter-package.json