From bb6425028308ed4f3eea107646afbaba371520b5 Mon Sep 17 00:00:00 2001 From: mcgallan <88413158+mcgallan@users.noreply.github.com> Date: Fri, 19 Jan 2024 13:46:17 +0800 Subject: [PATCH] Enable the new model serialization for Billingbenefits (#41096) --- .../CHANGELOG.md | 2 + ...eManager.BillingBenefits.netstandard2.0.cs | 147 +++++++++++++--- .../ArmBillingBenefitsModelFactory.cs | 24 +-- ...illingBenefitsReservationOrderAliasData.cs | 42 ++++- .../BillingBenefitsSavingsPlanData.cs | 42 ++++- ...illingBenefitsSavingsPlanOrderAliasData.cs | 42 ++++- .../BillingBenefitsSavingsPlanOrderData.cs | 41 ++++- .../BillingBenefitsSavingsPlanResource.cs | 4 +- .../MockableBillingBenefitsTenantResource.cs | 4 +- ...itsAppliedScopeProperties.Serialization.cs | 85 +++++++++- .../BillingBenefitsAppliedScopeProperties.cs | 37 +++- ...BillingBenefitsCommitment.Serialization.cs | 86 +++++++++- .../Models/BillingBenefitsCommitment.cs | 6 +- ...enefitsExtendedStatusInfo.Serialization.cs | 100 ++++++++++- .../BillingBenefitsExtendedStatusInfo.cs | 39 ++++- .../BillingBenefitsPrice.Serialization.cs | 86 +++++++++- .../Generated/Models/BillingBenefitsPrice.cs | 39 ++++- ...ngBenefitsPurchaseContent.Serialization.cs | 90 +++++++++- .../Models/BillingBenefitsPurchaseContent.cs | 37 +++- ...liasCreateOrUpdateContent.Serialization.cs | 105 +++++++++++- ...ervationOrderAliasCreateOrUpdateContent.cs | 42 ++++- ...ReservationOrderAliasData.Serialization.cs | 115 ++++++++++++- ...efitsRoleAssignmentEntity.Serialization.cs | 118 ++++++++++++- .../BillingBenefitsRoleAssignmentEntity.cs | 38 ++++- ...ngBenefitsSavingsPlanData.Serialization.cs | 160 +++++++++++++++++- ...SavingsPlanOrderAliasData.Serialization.cs | 116 ++++++++++++- ...efitsSavingsPlanOrderData.Serialization.cs | 134 ++++++++++++++- ...gBenefitsSavingsPlanPatch.Serialization.cs | 104 +++++++++++- .../Models/BillingBenefitsSavingsPlanPatch.cs | 39 ++++- ...avingsPlanPatchProperties.Serialization.cs | 140 ++++++++++++++- ...llingBenefitsSavingsPlanPatchProperties.cs | 39 ++++- ...itsSavingsPlanUtilization.Serialization.cs | 104 +++++++++++- .../BillingBenefitsSavingsPlanUtilization.cs | 37 +++- ...sPlanUtilizationAggregate.Serialization.cs | 110 +++++++++++- ...BenefitsSavingsPlanUtilizationAggregate.cs | 39 ++++- .../BillingBenefitsSku.Serialization.cs | 86 +++++++++- .../Generated/Models/BillingBenefitsSku.cs | 39 ++++- .../BillingPlanInformation.Serialization.cs | 84 ++++++++- .../Models/BillingPlanInformation.cs | 36 +++- .../Models/RenewProperties.Serialization.cs | 86 +++++++++- .../src/Generated/Models/RenewProperties.cs | 39 ++++- ...eservedResourceProperties.Serialization.cs | 86 +++++++++- ...estPropertiesReservedResourceProperties.cs | 39 ++++- ...eservedResourceProperties.Serialization.cs | 86 +++++++++- ...nsePropertiesReservedResourceProperties.cs | 39 ++++- .../SavingsPlanModelList.Serialization.cs | 104 +++++++++++- .../Generated/Models/SavingsPlanModelList.cs | 37 +++- ...avingsPlanModelListResult.Serialization.cs | 114 ++++++++++++- .../Models/SavingsPlanModelListResult.cs | 37 +++- ...SavingsPlanOrderModelList.Serialization.cs | 104 +++++++++++- .../Models/SavingsPlanOrderModelList.cs | 37 +++- ...ngsPlanOrderPaymentDetail.Serialization.cs | 90 +++++++++- .../Models/SavingsPlanOrderPaymentDetail.cs | 37 +++- ...anPurchaseValidateContent.Serialization.cs | 110 +++++++++++- .../SavingsPlanPurchaseValidateContent.cs | 37 +++- .../SavingsPlanSummary.Serialization.cs | 100 ++++++++++- .../Generated/Models/SavingsPlanSummary.cs | 39 ++++- .../SavingsPlanSummaryCount.Serialization.cs | 135 ++++++++++++++- .../Models/SavingsPlanSummaryCount.cs | 39 ++++- ...PlanUpdateValidateContent.Serialization.cs | 109 +++++++++++- .../SavingsPlanUpdateValidateContent.cs | 37 +++- ...vingsPlanValidateResponse.Serialization.cs | 104 +++++++++++- .../Models/SavingsPlanValidateResponse.cs | 37 +++- ...SavingsPlanValidateResult.Serialization.cs | 105 +++++++++++- .../Models/SavingsPlanValidateResult.cs | 39 ++++- .../src/autorest.md | 1 + ...sourceManager.BillingBenefits.Tests.csproj | 4 + ...iterImplementationValidation.Exceptions.cs | 16 ++ .../tests/Scenario/SavingsPlansTests.cs | 2 +- .../tests/TestHelpers.cs | 4 +- 70 files changed, 4320 insertions(+), 171 deletions(-) create mode 100644 sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/tests/ModelReaderWriterImplementationValidation.Exceptions.cs diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/CHANGELOG.md b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/CHANGELOG.md index 7efc31a52a50b..9cbdd336c4be9 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/CHANGELOG.md +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/CHANGELOG.md @@ -4,6 +4,8 @@ ### Features Added +- Enable the new model serialization by using the System.ClientModel, refer this [document](https://aka.ms/azsdk/net/mrw) for more details. + ### Breaking Changes ### Bugs Fixed diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/api/Azure.ResourceManager.BillingBenefits.netstandard2.0.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/api/Azure.ResourceManager.BillingBenefits.netstandard2.0.cs index 5d347bc0c8fb1..dd9797fafb26d 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/api/Azure.ResourceManager.BillingBenefits.netstandard2.0.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/api/Azure.ResourceManager.BillingBenefits.netstandard2.0.cs @@ -32,7 +32,7 @@ protected BillingBenefitsReservationOrderAliasCollection() { } public virtual Azure.NullableResponse GetIfExists(string reservationOrderAliasName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string reservationOrderAliasName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } - public partial class BillingBenefitsReservationOrderAliasData : Azure.ResourceManager.Models.ResourceData + public partial class BillingBenefitsReservationOrderAliasData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public BillingBenefitsReservationOrderAliasData(Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsSku sku) { } public Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsAppliedScopeProperties AppliedScopeProperties { get { throw null; } set { } } @@ -50,6 +50,11 @@ public BillingBenefitsReservationOrderAliasData(Azure.ResourceManager.BillingBen public System.DateTimeOffset? ReviewOn { get { throw null; } set { } } public string SkuName { get { throw null; } set { } } public Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsTerm? Term { get { throw null; } set { } } + Azure.ResourceManager.BillingBenefits.BillingBenefitsReservationOrderAliasData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.BillingBenefitsReservationOrderAliasData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class BillingBenefitsReservationOrderAliasResource : Azure.ResourceManager.ArmResource { @@ -78,7 +83,7 @@ protected BillingBenefitsSavingsPlanCollection() { } System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } } - public partial class BillingBenefitsSavingsPlanData : Azure.ResourceManager.Models.ResourceData + public partial class BillingBenefitsSavingsPlanData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public BillingBenefitsSavingsPlanData(Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsSku sku) { } public Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsAppliedScopeProperties AppliedScopeProperties { get { throw null; } set { } } @@ -105,6 +110,11 @@ public BillingBenefitsSavingsPlanData(Azure.ResourceManager.BillingBenefits.Mode public Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsTerm? Term { get { throw null; } set { } } public string UserFriendlyAppliedScopeType { get { throw null; } } public Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsSavingsPlanUtilization Utilization { get { throw null; } } + Azure.ResourceManager.BillingBenefits.BillingBenefitsSavingsPlanData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.BillingBenefitsSavingsPlanData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class BillingBenefitsSavingsPlanOrderAliasCollection : Azure.ResourceManager.ArmCollection { @@ -118,7 +128,7 @@ protected BillingBenefitsSavingsPlanOrderAliasCollection() { } public virtual Azure.NullableResponse GetIfExists(string savingsPlanOrderAliasName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string savingsPlanOrderAliasName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } - public partial class BillingBenefitsSavingsPlanOrderAliasData : Azure.ResourceManager.Models.ResourceData + public partial class BillingBenefitsSavingsPlanOrderAliasData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public BillingBenefitsSavingsPlanOrderAliasData(Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsSku sku) { } public Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsAppliedScopeProperties AppliedScopeProperties { get { throw null; } set { } } @@ -132,6 +142,11 @@ public BillingBenefitsSavingsPlanOrderAliasData(Azure.ResourceManager.BillingBen public Azure.Core.ResourceIdentifier SavingsPlanOrderId { get { throw null; } } public string SkuName { get { throw null; } set { } } public Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsTerm? Term { get { throw null; } set { } } + Azure.ResourceManager.BillingBenefits.BillingBenefitsSavingsPlanOrderAliasData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.BillingBenefitsSavingsPlanOrderAliasData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class BillingBenefitsSavingsPlanOrderAliasResource : Azure.ResourceManager.ArmResource { @@ -160,7 +175,7 @@ protected BillingBenefitsSavingsPlanOrderCollection() { } System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } } - public partial class BillingBenefitsSavingsPlanOrderData : Azure.ResourceManager.Models.ResourceData + public partial class BillingBenefitsSavingsPlanOrderData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public BillingBenefitsSavingsPlanOrderData(Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsSku sku) { } public System.DateTimeOffset? BenefitStartOn { get { throw null; } set { } } @@ -177,6 +192,11 @@ public BillingBenefitsSavingsPlanOrderData(Azure.ResourceManager.BillingBenefits public System.Collections.Generic.IList SavingsPlans { get { throw null; } } public string SkuName { get { throw null; } set { } } public Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsTerm? Term { get { throw null; } set { } } + Azure.ResourceManager.BillingBenefits.BillingBenefitsSavingsPlanOrderData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.BillingBenefitsSavingsPlanOrderData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class BillingBenefitsSavingsPlanOrderResource : Azure.ResourceManager.ArmResource { @@ -253,7 +273,7 @@ public static partial class ArmBillingBenefitsModelFactory public static Azure.ResourceManager.BillingBenefits.Models.SavingsPlanOrderPaymentDetail SavingsPlanOrderPaymentDetail(System.DateTimeOffset? dueOn = default(System.DateTimeOffset?), System.DateTimeOffset? payOn = default(System.DateTimeOffset?), Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsPrice pricingCurrencyTotal = null, Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsPrice billingCurrencyTotal = null, Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsPaymentStatus? status = default(Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsPaymentStatus?), Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsExtendedStatusInfo extendedStatusInfo = null, string billingAccount = null) { throw null; } public static Azure.ResourceManager.BillingBenefits.Models.SavingsPlanValidateResult SavingsPlanValidateResult(bool? isValid = default(bool?), string reasonCode = null, string reason = null) { throw null; } } - public partial class BillingBenefitsAppliedScopeProperties + public partial class BillingBenefitsAppliedScopeProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public BillingBenefitsAppliedScopeProperties() { } public string DisplayName { get { throw null; } set { } } @@ -261,6 +281,11 @@ public BillingBenefitsAppliedScopeProperties() { } public Azure.Core.ResourceIdentifier ResourceGroupId { get { throw null; } set { } } public Azure.Core.ResourceIdentifier SubscriptionId { get { throw null; } set { } } public System.Guid? TenantId { get { throw null; } set { } } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsAppliedScopeProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsAppliedScopeProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct BillingBenefitsAppliedScopeType : System.IEquatable @@ -298,10 +323,15 @@ public BillingBenefitsAppliedScopeProperties() { } public static bool operator !=(Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsBillingPlan left, Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsBillingPlan right) { throw null; } public override string ToString() { throw null; } } - public partial class BillingBenefitsCommitment : Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsPrice + public partial class BillingBenefitsCommitment : Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsPrice, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public BillingBenefitsCommitment() { } public Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsCommitmentGrain? Grain { get { throw null; } set { } } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsCommitment System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsCommitment System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct BillingBenefitsCommitmentGrain : System.IEquatable @@ -320,11 +350,16 @@ public BillingBenefitsCommitment() { } public static bool operator !=(Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsCommitmentGrain left, Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsCommitmentGrain right) { throw null; } public override string ToString() { throw null; } } - public partial class BillingBenefitsExtendedStatusInfo + public partial class BillingBenefitsExtendedStatusInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal BillingBenefitsExtendedStatusInfo() { } public string Message { get { throw null; } } public string StatusCode { get { throw null; } } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsExtendedStatusInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsExtendedStatusInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct BillingBenefitsInstanceFlexibility : System.IEquatable @@ -364,11 +399,16 @@ internal BillingBenefitsExtendedStatusInfo() { } public static bool operator !=(Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsPaymentStatus left, Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsPaymentStatus right) { throw null; } public override string ToString() { throw null; } } - public partial class BillingBenefitsPrice + public partial class BillingBenefitsPrice : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public BillingBenefitsPrice() { } public double? Amount { get { throw null; } set { } } public string CurrencyCode { get { throw null; } set { } } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsPrice System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsPrice System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct BillingBenefitsProvisioningState : System.IEquatable @@ -394,7 +434,7 @@ public BillingBenefitsPrice() { } public static bool operator !=(Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsProvisioningState left, Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsProvisioningState right) { throw null; } public override string ToString() { throw null; } } - public partial class BillingBenefitsPurchaseContent + public partial class BillingBenefitsPurchaseContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public BillingBenefitsPurchaseContent() { } public Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsAppliedScopeProperties AppliedScopeProperties { get { throw null; } set { } } @@ -407,8 +447,13 @@ public BillingBenefitsPurchaseContent() { } public bool? IsRenewed { get { throw null; } set { } } public string SkuName { get { throw null; } set { } } public Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsTerm? Term { get { throw null; } set { } } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsPurchaseContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsPurchaseContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class BillingBenefitsReservationOrderAliasCreateOrUpdateContent : Azure.ResourceManager.Models.ResourceData + public partial class BillingBenefitsReservationOrderAliasCreateOrUpdateContent : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public BillingBenefitsReservationOrderAliasCreateOrUpdateContent(Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsSku sku) { } public Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsAppliedScopeProperties AppliedScopeProperties { get { throw null; } set { } } @@ -424,6 +469,11 @@ public BillingBenefitsReservationOrderAliasCreateOrUpdateContent(Azure.ResourceM public System.DateTimeOffset? ReviewOn { get { throw null; } set { } } public string SkuName { get { throw null; } set { } } public Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsTerm? Term { get { throw null; } set { } } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsReservationOrderAliasCreateOrUpdateContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsReservationOrderAliasCreateOrUpdateContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct BillingBenefitsReservedResourceType : System.IEquatable @@ -467,7 +517,7 @@ public BillingBenefitsReservationOrderAliasCreateOrUpdateContent(Azure.ResourceM public static bool operator !=(Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsReservedResourceType left, Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsReservedResourceType right) { throw null; } public override string ToString() { throw null; } } - public partial class BillingBenefitsRoleAssignmentEntity + public partial class BillingBenefitsRoleAssignmentEntity : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal BillingBenefitsRoleAssignmentEntity() { } public Azure.Core.ResourceIdentifier Id { get { throw null; } } @@ -475,13 +525,23 @@ internal BillingBenefitsRoleAssignmentEntity() { } public string PrincipalId { get { throw null; } } public Azure.Core.ResourceIdentifier RoleDefinitionId { get { throw null; } } public Azure.Core.ResourceIdentifier Scope { get { throw null; } } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsRoleAssignmentEntity System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsRoleAssignmentEntity System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class BillingBenefitsSavingsPlanPatch + public partial class BillingBenefitsSavingsPlanPatch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public BillingBenefitsSavingsPlanPatch() { } public Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsSavingsPlanPatchProperties Properties { get { throw null; } set { } } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsSavingsPlanPatch System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsSavingsPlanPatch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class BillingBenefitsSavingsPlanPatchProperties + public partial class BillingBenefitsSavingsPlanPatchProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public BillingBenefitsSavingsPlanPatchProperties() { } public Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsAppliedScopeProperties AppliedScopeProperties { get { throw null; } set { } } @@ -489,25 +549,45 @@ public BillingBenefitsSavingsPlanPatchProperties() { } public string DisplayName { get { throw null; } set { } } public bool? IsRenewed { get { throw null; } set { } } public Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsPurchaseContent RenewPurchaseProperties { get { throw null; } set { } } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsSavingsPlanPatchProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsSavingsPlanPatchProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class BillingBenefitsSavingsPlanUtilization + public partial class BillingBenefitsSavingsPlanUtilization : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal BillingBenefitsSavingsPlanUtilization() { } public System.Collections.Generic.IReadOnlyList Aggregates { get { throw null; } } public string Trend { get { throw null; } } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsSavingsPlanUtilization System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsSavingsPlanUtilization System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class BillingBenefitsSavingsPlanUtilizationAggregate + public partial class BillingBenefitsSavingsPlanUtilizationAggregate : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal BillingBenefitsSavingsPlanUtilizationAggregate() { } public float? Grain { get { throw null; } } public string GrainUnit { get { throw null; } } public float? Value { get { throw null; } } public string ValueUnit { get { throw null; } } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsSavingsPlanUtilizationAggregate System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsSavingsPlanUtilizationAggregate System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class BillingBenefitsSku + public partial class BillingBenefitsSku : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public BillingBenefitsSku() { } public string Name { get { throw null; } set { } } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsSku System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsSku System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct BillingBenefitsTerm : System.IEquatable @@ -528,15 +608,20 @@ public BillingBenefitsSku() { } public static bool operator !=(Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsTerm left, Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsTerm right) { throw null; } public override string ToString() { throw null; } } - public partial class BillingPlanInformation + public partial class BillingPlanInformation : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public BillingPlanInformation() { } public System.DateTimeOffset? NextPaymentDueOn { get { throw null; } set { } } public Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsPrice PricingCurrencyTotal { get { throw null; } set { } } public System.DateTimeOffset? StartOn { get { throw null; } set { } } public System.Collections.Generic.IList Transactions { get { throw null; } } + Azure.ResourceManager.BillingBenefits.Models.BillingPlanInformation System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.Models.BillingPlanInformation System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SavingsPlanOrderPaymentDetail + public partial class SavingsPlanOrderPaymentDetail : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SavingsPlanOrderPaymentDetail() { } public string BillingAccount { get { throw null; } set { } } @@ -546,23 +631,43 @@ public SavingsPlanOrderPaymentDetail() { } public System.DateTimeOffset? PayOn { get { throw null; } set { } } public Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsPrice PricingCurrencyTotal { get { throw null; } set { } } public Azure.ResourceManager.BillingBenefits.Models.BillingBenefitsPaymentStatus? Status { get { throw null; } set { } } + Azure.ResourceManager.BillingBenefits.Models.SavingsPlanOrderPaymentDetail System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.Models.SavingsPlanOrderPaymentDetail System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SavingsPlanPurchaseValidateContent + public partial class SavingsPlanPurchaseValidateContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SavingsPlanPurchaseValidateContent() { } public System.Collections.Generic.IList Benefits { get { throw null; } } + Azure.ResourceManager.BillingBenefits.Models.SavingsPlanPurchaseValidateContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.Models.SavingsPlanPurchaseValidateContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SavingsPlanUpdateValidateContent + public partial class SavingsPlanUpdateValidateContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public SavingsPlanUpdateValidateContent() { } public System.Collections.Generic.IList Benefits { get { throw null; } } + Azure.ResourceManager.BillingBenefits.Models.SavingsPlanUpdateValidateContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.Models.SavingsPlanUpdateValidateContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class SavingsPlanValidateResult + public partial class SavingsPlanValidateResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal SavingsPlanValidateResult() { } public bool? IsValid { get { throw null; } } public string Reason { get { throw null; } } public string ReasonCode { get { throw null; } } + Azure.ResourceManager.BillingBenefits.Models.SavingsPlanValidateResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.BillingBenefits.Models.SavingsPlanValidateResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } public partial class TenantResourceGetBillingBenefitsSavingsPlansOptions { diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/ArmBillingBenefitsModelFactory.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/ArmBillingBenefitsModelFactory.cs index 1758da759f4e3..b48160852d565 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/ArmBillingBenefitsModelFactory.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/ArmBillingBenefitsModelFactory.cs @@ -36,7 +36,7 @@ public static partial class ArmBillingBenefitsModelFactory /// A new instance for mocking. public static BillingBenefitsSavingsPlanOrderAliasData BillingBenefitsSavingsPlanOrderAliasData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, string skuName = null, string kind = null, string displayName = null, ResourceIdentifier savingsPlanOrderId = null, BillingBenefitsProvisioningState? provisioningState = null, ResourceIdentifier billingScopeId = null, BillingBenefitsTerm? term = null, BillingBenefitsBillingPlan? billingPlan = null, BillingBenefitsAppliedScopeType? appliedScopeType = null, BillingBenefitsAppliedScopeProperties appliedScopeProperties = null, BillingBenefitsCommitment commitment = null) { - return new BillingBenefitsSavingsPlanOrderAliasData(id, name, resourceType, systemData, skuName != null ? new BillingBenefitsSku(skuName) : null, kind, displayName, savingsPlanOrderId, provisioningState, billingScopeId, term, billingPlan, appliedScopeType, appliedScopeProperties, commitment); + return new BillingBenefitsSavingsPlanOrderAliasData(id, name, resourceType, systemData, skuName != null ? new BillingBenefitsSku(skuName, serializedAdditionalRawData: null) : null, kind, displayName, savingsPlanOrderId, provisioningState, billingScopeId, term, billingPlan, appliedScopeType, appliedScopeProperties, commitment, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -63,7 +63,7 @@ public static BillingBenefitsSavingsPlanOrderData BillingBenefitsSavingsPlanOrde { savingsPlans ??= new List(); - return new BillingBenefitsSavingsPlanOrderData(id, name, resourceType, systemData, skuName != null ? new BillingBenefitsSku(skuName) : null, displayName, provisioningState, billingScopeId, billingProfileId, customerId, billingAccountId, term, billingPlan, expireOn, benefitStartOn, planInformation, savingsPlans?.ToList(), extendedStatusInfo); + return new BillingBenefitsSavingsPlanOrderData(id, name, resourceType, systemData, skuName != null ? new BillingBenefitsSku(skuName, serializedAdditionalRawData: null) : null, displayName, provisioningState, billingScopeId, billingProfileId, customerId, billingAccountId, term, billingPlan, expireOn, benefitStartOn, planInformation, savingsPlans?.ToList(), extendedStatusInfo, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -77,7 +77,7 @@ public static BillingBenefitsSavingsPlanOrderData BillingBenefitsSavingsPlanOrde /// A new instance for mocking. public static SavingsPlanOrderPaymentDetail SavingsPlanOrderPaymentDetail(DateTimeOffset? dueOn = null, DateTimeOffset? payOn = null, BillingBenefitsPrice pricingCurrencyTotal = null, BillingBenefitsPrice billingCurrencyTotal = null, BillingBenefitsPaymentStatus? status = null, BillingBenefitsExtendedStatusInfo extendedStatusInfo = null, string billingAccount = null) { - return new SavingsPlanOrderPaymentDetail(dueOn, payOn, pricingCurrencyTotal, billingCurrencyTotal, status, extendedStatusInfo, billingAccount); + return new SavingsPlanOrderPaymentDetail(dueOn, payOn, pricingCurrencyTotal, billingCurrencyTotal, status, extendedStatusInfo, billingAccount, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -86,7 +86,7 @@ public static SavingsPlanOrderPaymentDetail SavingsPlanOrderPaymentDetail(DateTi /// A new instance for mocking. public static BillingBenefitsExtendedStatusInfo BillingBenefitsExtendedStatusInfo(string statusCode = null, string message = null) { - return new BillingBenefitsExtendedStatusInfo(statusCode, message); + return new BillingBenefitsExtendedStatusInfo(statusCode, message, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -98,7 +98,7 @@ public static BillingBenefitsExtendedStatusInfo BillingBenefitsExtendedStatusInf /// A new instance for mocking. public static BillingBenefitsRoleAssignmentEntity BillingBenefitsRoleAssignmentEntity(ResourceIdentifier id = null, string name = null, string principalId = null, ResourceIdentifier roleDefinitionId = null, ResourceIdentifier scope = null) { - return new BillingBenefitsRoleAssignmentEntity(id, name, principalId, roleDefinitionId, scope); + return new BillingBenefitsRoleAssignmentEntity(id, name, principalId, roleDefinitionId, scope, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -133,7 +133,7 @@ public static BillingBenefitsRoleAssignmentEntity BillingBenefitsRoleAssignmentE /// A new instance for mocking. public static BillingBenefitsSavingsPlanData BillingBenefitsSavingsPlanData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, string skuName = null, string displayName = null, BillingBenefitsProvisioningState? provisioningState = null, string displayProvisioningState = null, ResourceIdentifier billingScopeId = null, ResourceIdentifier billingProfileId = null, string customerId = null, ResourceIdentifier billingAccountId = null, BillingBenefitsTerm? term = null, BillingBenefitsBillingPlan? billingPlan = null, BillingBenefitsAppliedScopeType? appliedScopeType = null, string userFriendlyAppliedScopeType = null, BillingBenefitsAppliedScopeProperties appliedScopeProperties = null, BillingBenefitsCommitment commitment = null, DateTimeOffset? effectOn = null, DateTimeOffset? expireOn = null, DateTimeOffset? purchaseOn = null, DateTimeOffset? benefitStartOn = null, BillingBenefitsExtendedStatusInfo extendedStatusInfo = null, bool? isRenewed = null, BillingBenefitsSavingsPlanUtilization utilization = null, string renewSource = null, string renewDestination = null, BillingBenefitsPurchaseContent renewPurchaseProperties = null) { - return new BillingBenefitsSavingsPlanData(id, name, resourceType, systemData, skuName != null ? new BillingBenefitsSku(skuName) : null, displayName, provisioningState, displayProvisioningState, billingScopeId, billingProfileId, customerId, billingAccountId, term, billingPlan, appliedScopeType, userFriendlyAppliedScopeType, appliedScopeProperties, commitment, effectOn, expireOn, purchaseOn, benefitStartOn, extendedStatusInfo, isRenewed, utilization, renewSource, renewDestination, renewPurchaseProperties != null ? new RenewProperties(renewPurchaseProperties) : null); + return new BillingBenefitsSavingsPlanData(id, name, resourceType, systemData, skuName != null ? new BillingBenefitsSku(skuName, serializedAdditionalRawData: null) : null, displayName, provisioningState, displayProvisioningState, billingScopeId, billingProfileId, customerId, billingAccountId, term, billingPlan, appliedScopeType, userFriendlyAppliedScopeType, appliedScopeProperties, commitment, effectOn, expireOn, purchaseOn, benefitStartOn, extendedStatusInfo, isRenewed, utilization, renewSource, renewDestination, renewPurchaseProperties != null ? new RenewProperties(renewPurchaseProperties, serializedAdditionalRawData: null) : null, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -144,7 +144,7 @@ public static BillingBenefitsSavingsPlanUtilization BillingBenefitsSavingsPlanUt { aggregates ??= new List(); - return new BillingBenefitsSavingsPlanUtilization(trend, aggregates?.ToList()); + return new BillingBenefitsSavingsPlanUtilization(trend, aggregates?.ToList(), serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -155,7 +155,7 @@ public static BillingBenefitsSavingsPlanUtilization BillingBenefitsSavingsPlanUt /// A new instance for mocking. public static BillingBenefitsSavingsPlanUtilizationAggregate BillingBenefitsSavingsPlanUtilizationAggregate(float? grain = null, string grainUnit = null, float? value = null, string valueUnit = null) { - return new BillingBenefitsSavingsPlanUtilizationAggregate(grain, grainUnit, value, valueUnit); + return new BillingBenefitsSavingsPlanUtilizationAggregate(grain, grainUnit, value, valueUnit, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -172,7 +172,7 @@ public static BillingBenefitsSavingsPlanUtilizationAggregate BillingBenefitsSavi /// A new instance for mocking. public static BillingBenefitsPurchaseContent BillingBenefitsPurchaseContent(string skuName = null, string displayName = null, ResourceIdentifier billingScopeId = null, BillingBenefitsTerm? term = null, BillingBenefitsBillingPlan? billingPlan = null, BillingBenefitsAppliedScopeType? appliedScopeType = null, BillingBenefitsCommitment commitment = null, DateTimeOffset? effectOn = null, bool? isRenewed = null, BillingBenefitsAppliedScopeProperties appliedScopeProperties = null) { - return new BillingBenefitsPurchaseContent(skuName != null ? new BillingBenefitsSku(skuName) : null, displayName, billingScopeId, term, billingPlan, appliedScopeType, commitment, effectOn, isRenewed, appliedScopeProperties); + return new BillingBenefitsPurchaseContent(skuName != null ? new BillingBenefitsSku(skuName, serializedAdditionalRawData: null) : null, displayName, billingScopeId, term, billingPlan, appliedScopeType, commitment, effectOn, isRenewed, appliedScopeProperties, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -182,7 +182,7 @@ public static BillingBenefitsPurchaseContent BillingBenefitsPurchaseContent(stri /// A new instance for mocking. public static SavingsPlanValidateResult SavingsPlanValidateResult(bool? isValid = null, string reasonCode = null, string reason = null) { - return new SavingsPlanValidateResult(isValid, reasonCode, reason); + return new SavingsPlanValidateResult(isValid, reasonCode, reason, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -206,7 +206,7 @@ public static SavingsPlanValidateResult SavingsPlanValidateResult(bool? isValid /// A new instance for mocking. public static BillingBenefitsReservationOrderAliasCreateOrUpdateContent BillingBenefitsReservationOrderAliasCreateOrUpdateContent(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, string skuName = null, AzureLocation? location = null, string displayName = null, ResourceIdentifier billingScopeId = null, BillingBenefitsTerm? term = null, BillingBenefitsBillingPlan? billingPlan = null, BillingBenefitsAppliedScopeType? appliedScopeType = null, BillingBenefitsAppliedScopeProperties appliedScopeProperties = null, int? quantity = null, bool? isRenewed = null, BillingBenefitsReservedResourceType? reservedResourceType = null, DateTimeOffset? reviewOn = null, BillingBenefitsInstanceFlexibility? reservedResourceInstanceFlexibility = null) { - return new BillingBenefitsReservationOrderAliasCreateOrUpdateContent(id, name, resourceType, systemData, skuName != null ? new BillingBenefitsSku(skuName) : null, location, displayName, billingScopeId, term, billingPlan, appliedScopeType, appliedScopeProperties, quantity, isRenewed, reservedResourceType, reviewOn, reservedResourceInstanceFlexibility != null ? new ReservationOrderAliasRequestPropertiesReservedResourceProperties(reservedResourceInstanceFlexibility) : null); + return new BillingBenefitsReservationOrderAliasCreateOrUpdateContent(id, name, resourceType, systemData, skuName != null ? new BillingBenefitsSku(skuName, serializedAdditionalRawData: null) : null, location, displayName, billingScopeId, term, billingPlan, appliedScopeType, appliedScopeProperties, quantity, isRenewed, reservedResourceType, reviewOn, reservedResourceInstanceFlexibility != null ? new ReservationOrderAliasRequestPropertiesReservedResourceProperties(reservedResourceInstanceFlexibility, serializedAdditionalRawData: null) : null, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -232,7 +232,7 @@ public static BillingBenefitsReservationOrderAliasCreateOrUpdateContent BillingB /// A new instance for mocking. public static BillingBenefitsReservationOrderAliasData BillingBenefitsReservationOrderAliasData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, string skuName = null, AzureLocation? location = null, string displayName = null, ResourceIdentifier reservationOrderId = null, BillingBenefitsProvisioningState? provisioningState = null, ResourceIdentifier billingScopeId = null, BillingBenefitsTerm? term = null, BillingBenefitsBillingPlan? billingPlan = null, BillingBenefitsAppliedScopeType? appliedScopeType = null, BillingBenefitsAppliedScopeProperties appliedScopeProperties = null, int? quantity = null, bool? isRenewed = null, BillingBenefitsReservedResourceType? reservedResourceType = null, DateTimeOffset? reviewOn = null, BillingBenefitsInstanceFlexibility? reservedResourceInstanceFlexibility = null) { - return new BillingBenefitsReservationOrderAliasData(id, name, resourceType, systemData, skuName != null ? new BillingBenefitsSku(skuName) : null, location, displayName, reservationOrderId, provisioningState, billingScopeId, term, billingPlan, appliedScopeType, appliedScopeProperties, quantity, isRenewed, reservedResourceType, reviewOn, reservedResourceInstanceFlexibility != null ? new ReservationOrderAliasResponsePropertiesReservedResourceProperties(reservedResourceInstanceFlexibility) : null); + return new BillingBenefitsReservationOrderAliasData(id, name, resourceType, systemData, skuName != null ? new BillingBenefitsSku(skuName, serializedAdditionalRawData: null) : null, location, displayName, reservationOrderId, provisioningState, billingScopeId, term, billingPlan, appliedScopeType, appliedScopeProperties, quantity, isRenewed, reservedResourceType, reviewOn, reservedResourceInstanceFlexibility != null ? new ReservationOrderAliasResponsePropertiesReservedResourceProperties(reservedResourceInstanceFlexibility, serializedAdditionalRawData: null) : null, serializedAdditionalRawData: null); } } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsReservationOrderAliasData.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsReservationOrderAliasData.cs index 53096755b59f8..c6fc55ac699d8 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsReservationOrderAliasData.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsReservationOrderAliasData.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.BillingBenefits.Models; using Azure.ResourceManager.Models; @@ -18,6 +19,38 @@ namespace Azure.ResourceManager.BillingBenefits /// public partial class BillingBenefitsReservationOrderAliasData : ResourceData { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . /// Reservation order SKU. /// is null. @@ -48,7 +81,8 @@ public BillingBenefitsReservationOrderAliasData(BillingBenefitsSku sku) /// The type of the resource that is being reserved. /// This is the date-time when the Reservation needs to be reviewed. /// Properties specific to each reserved resource type. Not required if not applicable. - internal BillingBenefitsReservationOrderAliasData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, BillingBenefitsSku sku, AzureLocation? location, string displayName, ResourceIdentifier reservationOrderId, BillingBenefitsProvisioningState? provisioningState, ResourceIdentifier billingScopeId, BillingBenefitsTerm? term, BillingBenefitsBillingPlan? billingPlan, BillingBenefitsAppliedScopeType? appliedScopeType, BillingBenefitsAppliedScopeProperties appliedScopeProperties, int? quantity, bool? isRenewed, BillingBenefitsReservedResourceType? reservedResourceType, DateTimeOffset? reviewOn, ReservationOrderAliasResponsePropertiesReservedResourceProperties reservedResourceProperties) : base(id, name, resourceType, systemData) + /// Keeps track of any properties unknown to the library. + internal BillingBenefitsReservationOrderAliasData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, BillingBenefitsSku sku, AzureLocation? location, string displayName, ResourceIdentifier reservationOrderId, BillingBenefitsProvisioningState? provisioningState, ResourceIdentifier billingScopeId, BillingBenefitsTerm? term, BillingBenefitsBillingPlan? billingPlan, BillingBenefitsAppliedScopeType? appliedScopeType, BillingBenefitsAppliedScopeProperties appliedScopeProperties, int? quantity, bool? isRenewed, BillingBenefitsReservedResourceType? reservedResourceType, DateTimeOffset? reviewOn, ReservationOrderAliasResponsePropertiesReservedResourceProperties reservedResourceProperties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) { Sku = sku; Location = location; @@ -65,6 +99,12 @@ internal BillingBenefitsReservationOrderAliasData(ResourceIdentifier id, string ReservedResourceType = reservedResourceType; ReviewOn = reviewOn; ReservedResourceProperties = reservedResourceProperties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BillingBenefitsReservationOrderAliasData() + { } /// Reservation order SKU. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsSavingsPlanData.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsSavingsPlanData.cs index d5ef6c9a76310..aaeae977e8a48 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsSavingsPlanData.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsSavingsPlanData.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.BillingBenefits.Models; using Azure.ResourceManager.Models; @@ -18,6 +19,38 @@ namespace Azure.ResourceManager.BillingBenefits /// public partial class BillingBenefitsSavingsPlanData : ResourceData { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . /// Savings plan SKU. /// is null. @@ -57,7 +90,8 @@ public BillingBenefitsSavingsPlanData(BillingBenefitsSku sku) /// SavingsPlan Id of the SavingsPlan from which this SavingsPlan is renewed. /// SavingsPlan Id of the SavingsPlan which is purchased because of renew. /// - internal BillingBenefitsSavingsPlanData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, BillingBenefitsSku sku, string displayName, BillingBenefitsProvisioningState? provisioningState, string displayProvisioningState, ResourceIdentifier billingScopeId, ResourceIdentifier billingProfileId, string customerId, ResourceIdentifier billingAccountId, BillingBenefitsTerm? term, BillingBenefitsBillingPlan? billingPlan, BillingBenefitsAppliedScopeType? appliedScopeType, string userFriendlyAppliedScopeType, BillingBenefitsAppliedScopeProperties appliedScopeProperties, BillingBenefitsCommitment commitment, DateTimeOffset? effectOn, DateTimeOffset? expireOn, DateTimeOffset? purchaseOn, DateTimeOffset? benefitStartOn, BillingBenefitsExtendedStatusInfo extendedStatusInfo, bool? isRenewed, BillingBenefitsSavingsPlanUtilization utilization, string renewSource, string renewDestination, RenewProperties renewProperties) : base(id, name, resourceType, systemData) + /// Keeps track of any properties unknown to the library. + internal BillingBenefitsSavingsPlanData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, BillingBenefitsSku sku, string displayName, BillingBenefitsProvisioningState? provisioningState, string displayProvisioningState, ResourceIdentifier billingScopeId, ResourceIdentifier billingProfileId, string customerId, ResourceIdentifier billingAccountId, BillingBenefitsTerm? term, BillingBenefitsBillingPlan? billingPlan, BillingBenefitsAppliedScopeType? appliedScopeType, string userFriendlyAppliedScopeType, BillingBenefitsAppliedScopeProperties appliedScopeProperties, BillingBenefitsCommitment commitment, DateTimeOffset? effectOn, DateTimeOffset? expireOn, DateTimeOffset? purchaseOn, DateTimeOffset? benefitStartOn, BillingBenefitsExtendedStatusInfo extendedStatusInfo, bool? isRenewed, BillingBenefitsSavingsPlanUtilization utilization, string renewSource, string renewDestination, RenewProperties renewProperties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) { Sku = sku; DisplayName = displayName; @@ -83,6 +117,12 @@ internal BillingBenefitsSavingsPlanData(ResourceIdentifier id, string name, Reso RenewSource = renewSource; RenewDestination = renewDestination; RenewProperties = renewProperties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BillingBenefitsSavingsPlanData() + { } /// Savings plan SKU. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsSavingsPlanOrderAliasData.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsSavingsPlanOrderAliasData.cs index 10a349530d0f4..2d2264331d795 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsSavingsPlanOrderAliasData.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsSavingsPlanOrderAliasData.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.BillingBenefits.Models; using Azure.ResourceManager.Models; @@ -18,6 +19,38 @@ namespace Azure.ResourceManager.BillingBenefits /// public partial class BillingBenefitsSavingsPlanOrderAliasData : ResourceData { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . /// Savings plan SKU. /// is null. @@ -44,7 +77,8 @@ public BillingBenefitsSavingsPlanOrderAliasData(BillingBenefitsSku sku) /// Type of the Applied Scope. /// Properties specific to applied scope type. Not required if not applicable. /// Commitment towards the benefit. - internal BillingBenefitsSavingsPlanOrderAliasData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, BillingBenefitsSku sku, string kind, string displayName, ResourceIdentifier savingsPlanOrderId, BillingBenefitsProvisioningState? provisioningState, ResourceIdentifier billingScopeId, BillingBenefitsTerm? term, BillingBenefitsBillingPlan? billingPlan, BillingBenefitsAppliedScopeType? appliedScopeType, BillingBenefitsAppliedScopeProperties appliedScopeProperties, BillingBenefitsCommitment commitment) : base(id, name, resourceType, systemData) + /// Keeps track of any properties unknown to the library. + internal BillingBenefitsSavingsPlanOrderAliasData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, BillingBenefitsSku sku, string kind, string displayName, ResourceIdentifier savingsPlanOrderId, BillingBenefitsProvisioningState? provisioningState, ResourceIdentifier billingScopeId, BillingBenefitsTerm? term, BillingBenefitsBillingPlan? billingPlan, BillingBenefitsAppliedScopeType? appliedScopeType, BillingBenefitsAppliedScopeProperties appliedScopeProperties, BillingBenefitsCommitment commitment, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) { Sku = sku; Kind = kind; @@ -57,6 +91,12 @@ internal BillingBenefitsSavingsPlanOrderAliasData(ResourceIdentifier id, string AppliedScopeType = appliedScopeType; AppliedScopeProperties = appliedScopeProperties; Commitment = commitment; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BillingBenefitsSavingsPlanOrderAliasData() + { } /// Savings plan SKU. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsSavingsPlanOrderData.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsSavingsPlanOrderData.cs index 2678d0258f464..87b06229d695b 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsSavingsPlanOrderData.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsSavingsPlanOrderData.cs @@ -19,6 +19,38 @@ namespace Azure.ResourceManager.BillingBenefits /// public partial class BillingBenefitsSavingsPlanOrderData : ResourceData { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . /// Savings plan SKU. /// is null. @@ -49,7 +81,8 @@ public BillingBenefitsSavingsPlanOrderData(BillingBenefitsSku sku) /// Information describing the type of billing plan for this savings plan. /// /// - internal BillingBenefitsSavingsPlanOrderData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, BillingBenefitsSku sku, string displayName, BillingBenefitsProvisioningState? provisioningState, ResourceIdentifier billingScopeId, ResourceIdentifier billingProfileId, string customerId, ResourceIdentifier billingAccountId, BillingBenefitsTerm? term, BillingBenefitsBillingPlan? billingPlan, DateTimeOffset? expireOn, DateTimeOffset? benefitStartOn, BillingPlanInformation planInformation, IList savingsPlans, BillingBenefitsExtendedStatusInfo extendedStatusInfo) : base(id, name, resourceType, systemData) + /// Keeps track of any properties unknown to the library. + internal BillingBenefitsSavingsPlanOrderData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, BillingBenefitsSku sku, string displayName, BillingBenefitsProvisioningState? provisioningState, ResourceIdentifier billingScopeId, ResourceIdentifier billingProfileId, string customerId, ResourceIdentifier billingAccountId, BillingBenefitsTerm? term, BillingBenefitsBillingPlan? billingPlan, DateTimeOffset? expireOn, DateTimeOffset? benefitStartOn, BillingPlanInformation planInformation, IList savingsPlans, BillingBenefitsExtendedStatusInfo extendedStatusInfo, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) { Sku = sku; DisplayName = displayName; @@ -65,6 +98,12 @@ internal BillingBenefitsSavingsPlanOrderData(ResourceIdentifier id, string name, PlanInformation = planInformation; SavingsPlans = savingsPlans; ExtendedStatusInfo = extendedStatusInfo; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BillingBenefitsSavingsPlanOrderData() + { } /// Savings plan SKU. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsSavingsPlanResource.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsSavingsPlanResource.cs index 8bffb089ffa81..c70a98d750bdc 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsSavingsPlanResource.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/BillingBenefitsSavingsPlanResource.cs @@ -287,7 +287,7 @@ public virtual AsyncPageable ValidateUpdateAsync(Savi HttpMessage FirstPageRequest(int? pageSizeHint) => _billingBenefitsSavingsPlanSavingsPlanRestClient.CreateValidateUpdateRequest(Id.Parent.Name, Id.Name, content); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _billingBenefitsSavingsPlanSavingsPlanRestClient.CreateValidateUpdateNextPageRequest(nextLink, Id.Parent.Name, Id.Name, content); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, SavingsPlanValidateResult.DeserializeSavingsPlanValidateResult, _billingBenefitsSavingsPlanSavingsPlanClientDiagnostics, Pipeline, "BillingBenefitsSavingsPlanResource.ValidateUpdate", "benefits", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => SavingsPlanValidateResult.DeserializeSavingsPlanValidateResult(e), _billingBenefitsSavingsPlanSavingsPlanClientDiagnostics, Pipeline, "BillingBenefitsSavingsPlanResource.ValidateUpdate", "benefits", "nextLink", cancellationToken); } /// @@ -321,7 +321,7 @@ public virtual Pageable ValidateUpdate(SavingsPlanUpd HttpMessage FirstPageRequest(int? pageSizeHint) => _billingBenefitsSavingsPlanSavingsPlanRestClient.CreateValidateUpdateRequest(Id.Parent.Name, Id.Name, content); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _billingBenefitsSavingsPlanSavingsPlanRestClient.CreateValidateUpdateNextPageRequest(nextLink, Id.Parent.Name, Id.Name, content); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, SavingsPlanValidateResult.DeserializeSavingsPlanValidateResult, _billingBenefitsSavingsPlanSavingsPlanClientDiagnostics, Pipeline, "BillingBenefitsSavingsPlanResource.ValidateUpdate", "benefits", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => SavingsPlanValidateResult.DeserializeSavingsPlanValidateResult(e), _billingBenefitsSavingsPlanSavingsPlanClientDiagnostics, Pipeline, "BillingBenefitsSavingsPlanResource.ValidateUpdate", "benefits", "nextLink", cancellationToken); } } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Extensions/MockableBillingBenefitsTenantResource.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Extensions/MockableBillingBenefitsTenantResource.cs index 31eb5fd4ce65b..0a6473feb2c87 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Extensions/MockableBillingBenefitsTenantResource.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Extensions/MockableBillingBenefitsTenantResource.cs @@ -351,7 +351,7 @@ public virtual AsyncPageable ValidatePurchaseAsync(Sa HttpMessage FirstPageRequest(int? pageSizeHint) => DefaultRestClient.CreateValidatePurchaseRequest(content); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => DefaultRestClient.CreateValidatePurchaseNextPageRequest(nextLink, content); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, SavingsPlanValidateResult.DeserializeSavingsPlanValidateResult, DefaultClientDiagnostics, Pipeline, "MockableBillingBenefitsTenantResource.ValidatePurchase", "benefits", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => SavingsPlanValidateResult.DeserializeSavingsPlanValidateResult(e), DefaultClientDiagnostics, Pipeline, "MockableBillingBenefitsTenantResource.ValidatePurchase", "benefits", "nextLink", cancellationToken); } /// @@ -381,7 +381,7 @@ public virtual Pageable ValidatePurchase(SavingsPlanP HttpMessage FirstPageRequest(int? pageSizeHint) => DefaultRestClient.CreateValidatePurchaseRequest(content); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => DefaultRestClient.CreateValidatePurchaseNextPageRequest(nextLink, content); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, SavingsPlanValidateResult.DeserializeSavingsPlanValidateResult, DefaultClientDiagnostics, Pipeline, "MockableBillingBenefitsTenantResource.ValidatePurchase", "benefits", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => SavingsPlanValidateResult.DeserializeSavingsPlanValidateResult(e), DefaultClientDiagnostics, Pipeline, "MockableBillingBenefitsTenantResource.ValidatePurchase", "benefits", "nextLink", cancellationToken); } } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsAppliedScopeProperties.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsAppliedScopeProperties.Serialization.cs index bbec5c5546949..164537a5b6d42 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsAppliedScopeProperties.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsAppliedScopeProperties.Serialization.cs @@ -6,15 +6,25 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - public partial class BillingBenefitsAppliedScopeProperties : IUtf8JsonSerializable + public partial class BillingBenefitsAppliedScopeProperties : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsAppliedScopeProperties)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(TenantId)) { @@ -41,11 +51,40 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("displayName"u8); writer.WriteStringValue(DisplayName); } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } - internal static BillingBenefitsAppliedScopeProperties DeserializeBillingBenefitsAppliedScopeProperties(JsonElement element) + BillingBenefitsAppliedScopeProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsAppliedScopeProperties)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBillingBenefitsAppliedScopeProperties(document.RootElement, options); + } + + internal static BillingBenefitsAppliedScopeProperties DeserializeBillingBenefitsAppliedScopeProperties(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -55,6 +94,8 @@ internal static BillingBenefitsAppliedScopeProperties DeserializeBillingBenefits Optional subscriptionId = default; Optional resourceGroupId = default; Optional displayName = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("tenantId"u8)) @@ -98,8 +139,44 @@ internal static BillingBenefitsAppliedScopeProperties DeserializeBillingBenefits displayName = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new BillingBenefitsAppliedScopeProperties(Optional.ToNullable(tenantId), managementGroupId.Value, subscriptionId.Value, resourceGroupId.Value, displayName.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new BillingBenefitsAppliedScopeProperties(Optional.ToNullable(tenantId), managementGroupId.Value, subscriptionId.Value, resourceGroupId.Value, displayName.Value, serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BillingBenefitsAppliedScopeProperties)} does not support '{options.Format}' format."); + } + } + + BillingBenefitsAppliedScopeProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBillingBenefitsAppliedScopeProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BillingBenefitsAppliedScopeProperties)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsAppliedScopeProperties.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsAppliedScopeProperties.cs index 8e2297354f9ce..3e13346ef59f4 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsAppliedScopeProperties.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsAppliedScopeProperties.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.BillingBenefits.Models /// Properties specific to applied scope type. Not required if not applicable. public partial class BillingBenefitsAppliedScopeProperties { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . public BillingBenefitsAppliedScopeProperties() { @@ -24,13 +57,15 @@ public BillingBenefitsAppliedScopeProperties() /// Fully-qualified identifier of the subscription. /// Fully-qualified identifier of the resource group. /// Display name. - internal BillingBenefitsAppliedScopeProperties(Guid? tenantId, ResourceIdentifier managementGroupId, ResourceIdentifier subscriptionId, ResourceIdentifier resourceGroupId, string displayName) + /// Keeps track of any properties unknown to the library. + internal BillingBenefitsAppliedScopeProperties(Guid? tenantId, ResourceIdentifier managementGroupId, ResourceIdentifier subscriptionId, ResourceIdentifier resourceGroupId, string displayName, IDictionary serializedAdditionalRawData) { TenantId = tenantId; ManagementGroupId = managementGroupId; SubscriptionId = subscriptionId; ResourceGroupId = resourceGroupId; DisplayName = displayName; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Tenant ID where the benefit is applied. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsCommitment.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsCommitment.Serialization.cs index 89c4f190736d2..22f91abd7b553 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsCommitment.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsCommitment.Serialization.cs @@ -5,15 +5,26 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - public partial class BillingBenefitsCommitment : IUtf8JsonSerializable + public partial class BillingBenefitsCommitment : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsCommitment)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(Grain)) { @@ -30,11 +41,40 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("amount"u8); writer.WriteNumberValue(Amount.Value); } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } - internal static BillingBenefitsCommitment DeserializeBillingBenefitsCommitment(JsonElement element) + BillingBenefitsCommitment IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsCommitment)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBillingBenefitsCommitment(document.RootElement, options); + } + + internal static BillingBenefitsCommitment DeserializeBillingBenefitsCommitment(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -42,6 +82,8 @@ internal static BillingBenefitsCommitment DeserializeBillingBenefitsCommitment(J Optional grain = default; Optional currencyCode = default; Optional amount = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("grain"u8)) @@ -67,8 +109,44 @@ internal static BillingBenefitsCommitment DeserializeBillingBenefitsCommitment(J amount = property.Value.GetDouble(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new BillingBenefitsCommitment(currencyCode.Value, Optional.ToNullable(amount), Optional.ToNullable(grain)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new BillingBenefitsCommitment(currencyCode.Value, Optional.ToNullable(amount), serializedAdditionalRawData, Optional.ToNullable(grain)); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BillingBenefitsCommitment)} does not support '{options.Format}' format."); + } + } + + BillingBenefitsCommitment IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBillingBenefitsCommitment(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BillingBenefitsCommitment)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsCommitment.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsCommitment.cs index f5f1c69e5af50..59878edfd1035 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsCommitment.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsCommitment.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.BillingBenefits.Models { /// Commitment towards the benefit. @@ -18,8 +21,9 @@ public BillingBenefitsCommitment() /// Initializes a new instance of . /// The ISO 4217 3-letter currency code for the currency used by this purchase record. /// + /// Keeps track of any properties unknown to the library. /// Commitment grain. - internal BillingBenefitsCommitment(string currencyCode, double? amount, BillingBenefitsCommitmentGrain? grain) : base(currencyCode, amount) + internal BillingBenefitsCommitment(string currencyCode, double? amount, IDictionary serializedAdditionalRawData, BillingBenefitsCommitmentGrain? grain) : base(currencyCode, amount, serializedAdditionalRawData) { Grain = grain; } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsExtendedStatusInfo.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsExtendedStatusInfo.Serialization.cs index 85915c444a0ae..8b9429eee9801 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsExtendedStatusInfo.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsExtendedStatusInfo.Serialization.cs @@ -5,21 +5,79 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - public partial class BillingBenefitsExtendedStatusInfo + public partial class BillingBenefitsExtendedStatusInfo : IUtf8JsonSerializable, IJsonModel { - internal static BillingBenefitsExtendedStatusInfo DeserializeBillingBenefitsExtendedStatusInfo(JsonElement element) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsExtendedStatusInfo)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(StatusCode)) + { + writer.WritePropertyName("statusCode"u8); + writer.WriteStringValue(StatusCode); + } + if (Optional.IsDefined(Message)) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BillingBenefitsExtendedStatusInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsExtendedStatusInfo)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBillingBenefitsExtendedStatusInfo(document.RootElement, options); + } + + internal static BillingBenefitsExtendedStatusInfo DeserializeBillingBenefitsExtendedStatusInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional statusCode = default; Optional message = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("statusCode"u8)) @@ -32,8 +90,44 @@ internal static BillingBenefitsExtendedStatusInfo DeserializeBillingBenefitsExte message = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new BillingBenefitsExtendedStatusInfo(statusCode.Value, message.Value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BillingBenefitsExtendedStatusInfo)} does not support '{options.Format}' format."); } - return new BillingBenefitsExtendedStatusInfo(statusCode.Value, message.Value); } + + BillingBenefitsExtendedStatusInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBillingBenefitsExtendedStatusInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BillingBenefitsExtendedStatusInfo)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsExtendedStatusInfo.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsExtendedStatusInfo.cs index fc3a1374f9b5b..3c794a68e1520 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsExtendedStatusInfo.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsExtendedStatusInfo.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.BillingBenefits.Models { /// The BillingBenefitsExtendedStatusInfo. public partial class BillingBenefitsExtendedStatusInfo { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . internal BillingBenefitsExtendedStatusInfo() { @@ -18,10 +53,12 @@ internal BillingBenefitsExtendedStatusInfo() /// Initializes a new instance of . /// Status code providing additional information. /// The message giving detailed information about the status code. - internal BillingBenefitsExtendedStatusInfo(string statusCode, string message) + /// Keeps track of any properties unknown to the library. + internal BillingBenefitsExtendedStatusInfo(string statusCode, string message, IDictionary serializedAdditionalRawData) { StatusCode = statusCode; Message = message; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Status code providing additional information. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsPrice.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsPrice.Serialization.cs index 4f47200a52b81..c28ad9ea0d68e 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsPrice.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsPrice.Serialization.cs @@ -5,15 +5,26 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - public partial class BillingBenefitsPrice : IUtf8JsonSerializable + public partial class BillingBenefitsPrice : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsPrice)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(CurrencyCode)) { @@ -25,17 +36,48 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("amount"u8); writer.WriteNumberValue(Amount.Value); } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } - internal static BillingBenefitsPrice DeserializeBillingBenefitsPrice(JsonElement element) + BillingBenefitsPrice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsPrice)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBillingBenefitsPrice(document.RootElement, options); + } + + internal static BillingBenefitsPrice DeserializeBillingBenefitsPrice(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional currencyCode = default; Optional amount = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("currencyCode"u8)) @@ -52,8 +94,44 @@ internal static BillingBenefitsPrice DeserializeBillingBenefitsPrice(JsonElement amount = property.Value.GetDouble(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new BillingBenefitsPrice(currencyCode.Value, Optional.ToNullable(amount)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new BillingBenefitsPrice(currencyCode.Value, Optional.ToNullable(amount), serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BillingBenefitsPrice)} does not support '{options.Format}' format."); + } + } + + BillingBenefitsPrice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBillingBenefitsPrice(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BillingBenefitsPrice)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsPrice.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsPrice.cs index b653ace841a23..36123b8237800 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsPrice.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsPrice.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.BillingBenefits.Models { /// The BillingBenefitsPrice. public partial class BillingBenefitsPrice { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . public BillingBenefitsPrice() { @@ -18,10 +53,12 @@ public BillingBenefitsPrice() /// Initializes a new instance of . /// The ISO 4217 3-letter currency code for the currency used by this purchase record. /// - internal BillingBenefitsPrice(string currencyCode, double? amount) + /// Keeps track of any properties unknown to the library. + internal BillingBenefitsPrice(string currencyCode, double? amount, IDictionary serializedAdditionalRawData) { CurrencyCode = currencyCode; Amount = amount; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The ISO 4217 3-letter currency code for the currency used by this purchase record. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsPurchaseContent.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsPurchaseContent.Serialization.cs index 7a4cfe7d3575c..881c83d4f98fa 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsPurchaseContent.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsPurchaseContent.Serialization.cs @@ -6,15 +6,25 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - public partial class BillingBenefitsPurchaseContent : IUtf8JsonSerializable + public partial class BillingBenefitsPurchaseContent : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsPurchaseContent)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(Sku)) { @@ -53,6 +63,11 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("commitment"u8); writer.WriteObjectValue(Commitment); } + if (options.Format != "W" && Optional.IsDefined(EffectOn)) + { + writer.WritePropertyName("effectiveDateTime"u8); + writer.WriteStringValue(EffectOn.Value, "O"); + } if (Optional.IsDefined(IsRenewed)) { writer.WritePropertyName("renew"u8); @@ -64,11 +79,40 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteObjectValue(AppliedScopeProperties); } writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } - internal static BillingBenefitsPurchaseContent DeserializeBillingBenefitsPurchaseContent(JsonElement element) + BillingBenefitsPurchaseContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsPurchaseContent)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBillingBenefitsPurchaseContent(document.RootElement, options); + } + + internal static BillingBenefitsPurchaseContent DeserializeBillingBenefitsPurchaseContent(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -83,6 +127,8 @@ internal static BillingBenefitsPurchaseContent DeserializeBillingBenefitsPurchas Optional effectiveDateTime = default; Optional renew = default; Optional appliedScopeProperties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("sku"u8)) @@ -183,8 +229,44 @@ internal static BillingBenefitsPurchaseContent DeserializeBillingBenefitsPurchas } continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new BillingBenefitsPurchaseContent(sku.Value, displayName.Value, billingScopeId.Value, Optional.ToNullable(term), Optional.ToNullable(billingPlan), Optional.ToNullable(appliedScopeType), commitment.Value, Optional.ToNullable(effectiveDateTime), Optional.ToNullable(renew), appliedScopeProperties.Value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BillingBenefitsPurchaseContent)} does not support '{options.Format}' format."); } - return new BillingBenefitsPurchaseContent(sku.Value, displayName.Value, billingScopeId.Value, Optional.ToNullable(term), Optional.ToNullable(billingPlan), Optional.ToNullable(appliedScopeType), commitment.Value, Optional.ToNullable(effectiveDateTime), Optional.ToNullable(renew), appliedScopeProperties.Value); } + + BillingBenefitsPurchaseContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBillingBenefitsPurchaseContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BillingBenefitsPurchaseContent)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsPurchaseContent.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsPurchaseContent.cs index fd1a551b5a2b5..a7e5115296e3b 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsPurchaseContent.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsPurchaseContent.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.BillingBenefits.Models /// The BillingBenefitsPurchaseContent. public partial class BillingBenefitsPurchaseContent { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . public BillingBenefitsPurchaseContent() { @@ -29,7 +62,8 @@ public BillingBenefitsPurchaseContent() /// DateTime of the savings plan starts providing benefit from. /// Setting this to true will automatically purchase a new benefit on the expiration date time. /// Properties specific to applied scope type. Not required if not applicable. - internal BillingBenefitsPurchaseContent(BillingBenefitsSku sku, string displayName, ResourceIdentifier billingScopeId, BillingBenefitsTerm? term, BillingBenefitsBillingPlan? billingPlan, BillingBenefitsAppliedScopeType? appliedScopeType, BillingBenefitsCommitment commitment, DateTimeOffset? effectOn, bool? isRenewed, BillingBenefitsAppliedScopeProperties appliedScopeProperties) + /// Keeps track of any properties unknown to the library. + internal BillingBenefitsPurchaseContent(BillingBenefitsSku sku, string displayName, ResourceIdentifier billingScopeId, BillingBenefitsTerm? term, BillingBenefitsBillingPlan? billingPlan, BillingBenefitsAppliedScopeType? appliedScopeType, BillingBenefitsCommitment commitment, DateTimeOffset? effectOn, bool? isRenewed, BillingBenefitsAppliedScopeProperties appliedScopeProperties, IDictionary serializedAdditionalRawData) { Sku = sku; DisplayName = displayName; @@ -41,6 +75,7 @@ internal BillingBenefitsPurchaseContent(BillingBenefitsSku sku, string displayNa EffectOn = effectOn; IsRenewed = isRenewed; AppliedScopeProperties = appliedScopeProperties; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The SKU to be applied for this resource. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsReservationOrderAliasCreateOrUpdateContent.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsReservationOrderAliasCreateOrUpdateContent.Serialization.cs index 7fcab4e80b8e9..e3467f1911691 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsReservationOrderAliasCreateOrUpdateContent.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsReservationOrderAliasCreateOrUpdateContent.Serialization.cs @@ -6,16 +6,26 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.BillingBenefits.Models { - public partial class BillingBenefitsReservationOrderAliasCreateOrUpdateContent : IUtf8JsonSerializable + public partial class BillingBenefitsReservationOrderAliasCreateOrUpdateContent : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsReservationOrderAliasCreateOrUpdateContent)} does not support '{format}' format."); + } + writer.WriteStartObject(); writer.WritePropertyName("sku"u8); writer.WriteObjectValue(Sku); @@ -24,6 +34,26 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("location"u8); writer.WriteStringValue(Location.Value); } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(DisplayName)) @@ -82,11 +112,40 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteObjectValue(ReservedResourceProperties); } writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } - internal static BillingBenefitsReservationOrderAliasCreateOrUpdateContent DeserializeBillingBenefitsReservationOrderAliasCreateOrUpdateContent(JsonElement element) + BillingBenefitsReservationOrderAliasCreateOrUpdateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsReservationOrderAliasCreateOrUpdateContent)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBillingBenefitsReservationOrderAliasCreateOrUpdateContent(document.RootElement, options); + } + + internal static BillingBenefitsReservationOrderAliasCreateOrUpdateContent DeserializeBillingBenefitsReservationOrderAliasCreateOrUpdateContent(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -108,6 +167,8 @@ internal static BillingBenefitsReservationOrderAliasCreateOrUpdateContent Deseri Optional reservedResourceType = default; Optional reviewDateTime = default; Optional reservedResourceProperties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("sku"u8)) @@ -255,8 +316,44 @@ internal static BillingBenefitsReservationOrderAliasCreateOrUpdateContent Deseri } continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new BillingBenefitsReservationOrderAliasCreateOrUpdateContent(id, name, type, systemData.Value, sku, Optional.ToNullable(location), displayName.Value, billingScopeId.Value, Optional.ToNullable(term), Optional.ToNullable(billingPlan), Optional.ToNullable(appliedScopeType), appliedScopeProperties.Value, Optional.ToNullable(quantity), Optional.ToNullable(renew), Optional.ToNullable(reservedResourceType), Optional.ToNullable(reviewDateTime), reservedResourceProperties.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new BillingBenefitsReservationOrderAliasCreateOrUpdateContent(id, name, type, systemData.Value, sku, Optional.ToNullable(location), displayName.Value, billingScopeId.Value, Optional.ToNullable(term), Optional.ToNullable(billingPlan), Optional.ToNullable(appliedScopeType), appliedScopeProperties.Value, Optional.ToNullable(quantity), Optional.ToNullable(renew), Optional.ToNullable(reservedResourceType), Optional.ToNullable(reviewDateTime), reservedResourceProperties.Value, serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BillingBenefitsReservationOrderAliasCreateOrUpdateContent)} does not support '{options.Format}' format."); + } + } + + BillingBenefitsReservationOrderAliasCreateOrUpdateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBillingBenefitsReservationOrderAliasCreateOrUpdateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BillingBenefitsReservationOrderAliasCreateOrUpdateContent)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsReservationOrderAliasCreateOrUpdateContent.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsReservationOrderAliasCreateOrUpdateContent.cs index 13df721f0156f..e6d480feb0936 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsReservationOrderAliasCreateOrUpdateContent.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsReservationOrderAliasCreateOrUpdateContent.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Models; @@ -14,6 +15,38 @@ namespace Azure.ResourceManager.BillingBenefits.Models /// Reservation order alias. public partial class BillingBenefitsReservationOrderAliasCreateOrUpdateContent : ResourceData { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . /// Reservation order SKU. /// is null. @@ -42,7 +75,8 @@ public BillingBenefitsReservationOrderAliasCreateOrUpdateContent(BillingBenefits /// The type of the resource that is being reserved. /// This is the date-time when the Azure Hybrid Benefit needs to be reviewed. /// Properties specific to each reserved resource type. Not required if not applicable. - internal BillingBenefitsReservationOrderAliasCreateOrUpdateContent(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, BillingBenefitsSku sku, AzureLocation? location, string displayName, ResourceIdentifier billingScopeId, BillingBenefitsTerm? term, BillingBenefitsBillingPlan? billingPlan, BillingBenefitsAppliedScopeType? appliedScopeType, BillingBenefitsAppliedScopeProperties appliedScopeProperties, int? quantity, bool? isRenewed, BillingBenefitsReservedResourceType? reservedResourceType, DateTimeOffset? reviewOn, ReservationOrderAliasRequestPropertiesReservedResourceProperties reservedResourceProperties) : base(id, name, resourceType, systemData) + /// Keeps track of any properties unknown to the library. + internal BillingBenefitsReservationOrderAliasCreateOrUpdateContent(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, BillingBenefitsSku sku, AzureLocation? location, string displayName, ResourceIdentifier billingScopeId, BillingBenefitsTerm? term, BillingBenefitsBillingPlan? billingPlan, BillingBenefitsAppliedScopeType? appliedScopeType, BillingBenefitsAppliedScopeProperties appliedScopeProperties, int? quantity, bool? isRenewed, BillingBenefitsReservedResourceType? reservedResourceType, DateTimeOffset? reviewOn, ReservationOrderAliasRequestPropertiesReservedResourceProperties reservedResourceProperties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) { Sku = sku; Location = location; @@ -57,6 +91,12 @@ internal BillingBenefitsReservationOrderAliasCreateOrUpdateContent(ResourceIdent ReservedResourceType = reservedResourceType; ReviewOn = reviewOn; ReservedResourceProperties = reservedResourceProperties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BillingBenefitsReservationOrderAliasCreateOrUpdateContent() + { } /// Reservation order SKU. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsReservationOrderAliasData.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsReservationOrderAliasData.Serialization.cs index a04ccdbd56fe5..60377b97981fe 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsReservationOrderAliasData.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsReservationOrderAliasData.Serialization.cs @@ -6,6 +6,8 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.BillingBenefits.Models; @@ -13,10 +15,18 @@ namespace Azure.ResourceManager.BillingBenefits { - public partial class BillingBenefitsReservationOrderAliasData : IUtf8JsonSerializable + public partial class BillingBenefitsReservationOrderAliasData : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsReservationOrderAliasData)} does not support '{format}' format."); + } + writer.WriteStartObject(); writer.WritePropertyName("sku"u8); writer.WriteObjectValue(Sku); @@ -25,6 +35,26 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("location"u8); writer.WriteStringValue(Location.Value); } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(DisplayName)) @@ -32,6 +62,16 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("displayName"u8); writer.WriteStringValue(DisplayName); } + if (options.Format != "W" && Optional.IsDefined(ReservationOrderId)) + { + writer.WritePropertyName("reservationOrderId"u8); + writer.WriteStringValue(ReservationOrderId); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } if (Optional.IsDefined(BillingScopeId)) { writer.WritePropertyName("billingScopeId"u8); @@ -83,11 +123,40 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteObjectValue(ReservedResourceProperties); } writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } - internal static BillingBenefitsReservationOrderAliasData DeserializeBillingBenefitsReservationOrderAliasData(JsonElement element) + BillingBenefitsReservationOrderAliasData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsReservationOrderAliasData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBillingBenefitsReservationOrderAliasData(document.RootElement, options); + } + + internal static BillingBenefitsReservationOrderAliasData DeserializeBillingBenefitsReservationOrderAliasData(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -111,6 +180,8 @@ internal static BillingBenefitsReservationOrderAliasData DeserializeBillingBenef Optional reservedResourceType = default; Optional reviewDateTime = default; Optional reservedResourceProperties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("sku"u8)) @@ -276,8 +347,44 @@ internal static BillingBenefitsReservationOrderAliasData DeserializeBillingBenef } continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new BillingBenefitsReservationOrderAliasData(id, name, type, systemData.Value, sku, Optional.ToNullable(location), displayName.Value, reservationOrderId.Value, Optional.ToNullable(provisioningState), billingScopeId.Value, Optional.ToNullable(term), Optional.ToNullable(billingPlan), Optional.ToNullable(appliedScopeType), appliedScopeProperties.Value, Optional.ToNullable(quantity), Optional.ToNullable(renew), Optional.ToNullable(reservedResourceType), Optional.ToNullable(reviewDateTime), reservedResourceProperties.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new BillingBenefitsReservationOrderAliasData(id, name, type, systemData.Value, sku, Optional.ToNullable(location), displayName.Value, reservationOrderId.Value, Optional.ToNullable(provisioningState), billingScopeId.Value, Optional.ToNullable(term), Optional.ToNullable(billingPlan), Optional.ToNullable(appliedScopeType), appliedScopeProperties.Value, Optional.ToNullable(quantity), Optional.ToNullable(renew), Optional.ToNullable(reservedResourceType), Optional.ToNullable(reviewDateTime), reservedResourceProperties.Value, serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BillingBenefitsReservationOrderAliasData)} does not support '{options.Format}' format."); + } + } + + BillingBenefitsReservationOrderAliasData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBillingBenefitsReservationOrderAliasData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BillingBenefitsReservationOrderAliasData)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsRoleAssignmentEntity.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsRoleAssignmentEntity.Serialization.cs index 68e542c3fec40..267d5ba8b4e07 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsRoleAssignmentEntity.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsRoleAssignmentEntity.Serialization.cs @@ -5,15 +5,89 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - public partial class BillingBenefitsRoleAssignmentEntity + public partial class BillingBenefitsRoleAssignmentEntity : IUtf8JsonSerializable, IJsonModel { - internal static BillingBenefitsRoleAssignmentEntity DeserializeBillingBenefitsRoleAssignmentEntity(JsonElement element) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsRoleAssignmentEntity)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(PrincipalId)) + { + writer.WritePropertyName("principalId"u8); + writer.WriteStringValue(PrincipalId); + } + if (Optional.IsDefined(RoleDefinitionId)) + { + writer.WritePropertyName("roleDefinitionId"u8); + writer.WriteStringValue(RoleDefinitionId); + } + if (Optional.IsDefined(Scope)) + { + writer.WritePropertyName("scope"u8); + writer.WriteStringValue(Scope); + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BillingBenefitsRoleAssignmentEntity IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsRoleAssignmentEntity)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBillingBenefitsRoleAssignmentEntity(document.RootElement, options); + } + + internal static BillingBenefitsRoleAssignmentEntity DeserializeBillingBenefitsRoleAssignmentEntity(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -23,6 +97,8 @@ internal static BillingBenefitsRoleAssignmentEntity DeserializeBillingBenefitsRo Optional principalId = default; Optional roleDefinitionId = default; Optional scope = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id"u8)) @@ -74,8 +150,44 @@ internal static BillingBenefitsRoleAssignmentEntity DeserializeBillingBenefitsRo } continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new BillingBenefitsRoleAssignmentEntity(id.Value, name.Value, principalId.Value, roleDefinitionId.Value, scope.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new BillingBenefitsRoleAssignmentEntity(id.Value, name.Value, principalId.Value, roleDefinitionId.Value, scope.Value, serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BillingBenefitsRoleAssignmentEntity)} does not support '{options.Format}' format."); + } + } + + BillingBenefitsRoleAssignmentEntity IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBillingBenefitsRoleAssignmentEntity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BillingBenefitsRoleAssignmentEntity)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsRoleAssignmentEntity.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsRoleAssignmentEntity.cs index 9ef243bfc5822..e889cadd565f2 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsRoleAssignmentEntity.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsRoleAssignmentEntity.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.Collections.Generic; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models @@ -12,6 +14,38 @@ namespace Azure.ResourceManager.BillingBenefits.Models /// Role assignment entity. public partial class BillingBenefitsRoleAssignmentEntity { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . internal BillingBenefitsRoleAssignmentEntity() { @@ -23,13 +57,15 @@ internal BillingBenefitsRoleAssignmentEntity() /// Principal Id. /// Role definition id. /// Scope of the role assignment entity. - internal BillingBenefitsRoleAssignmentEntity(ResourceIdentifier id, string name, string principalId, ResourceIdentifier roleDefinitionId, ResourceIdentifier scope) + /// Keeps track of any properties unknown to the library. + internal BillingBenefitsRoleAssignmentEntity(ResourceIdentifier id, string name, string principalId, ResourceIdentifier roleDefinitionId, ResourceIdentifier scope, IDictionary serializedAdditionalRawData) { Id = id; Name = name; PrincipalId = principalId; RoleDefinitionId = roleDefinitionId; Scope = scope; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Role assignment entity id. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanData.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanData.Serialization.cs index f40a6b78209ec..a20f2f8642fd4 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanData.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanData.Serialization.cs @@ -6,6 +6,8 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.BillingBenefits.Models; @@ -13,13 +15,41 @@ namespace Azure.ResourceManager.BillingBenefits { - public partial class BillingBenefitsSavingsPlanData : IUtf8JsonSerializable + public partial class BillingBenefitsSavingsPlanData : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanData)} does not support '{format}' format."); + } + writer.WriteStartObject(); writer.WritePropertyName("sku"u8); writer.WriteObjectValue(Sku); + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(DisplayName)) @@ -27,11 +57,36 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("displayName"u8); writer.WriteStringValue(DisplayName); } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(DisplayProvisioningState)) + { + writer.WritePropertyName("displayProvisioningState"u8); + writer.WriteStringValue(DisplayProvisioningState); + } if (Optional.IsDefined(BillingScopeId)) { writer.WritePropertyName("billingScopeId"u8); writer.WriteStringValue(BillingScopeId); } + if (options.Format != "W" && Optional.IsDefined(BillingProfileId)) + { + writer.WritePropertyName("billingProfileId"u8); + writer.WriteStringValue(BillingProfileId); + } + if (options.Format != "W" && Optional.IsDefined(CustomerId)) + { + writer.WritePropertyName("customerId"u8); + writer.WriteStringValue(CustomerId); + } + if (options.Format != "W" && Optional.IsDefined(BillingAccountId)) + { + writer.WritePropertyName("billingAccountId"u8); + writer.WriteStringValue(BillingAccountId); + } if (Optional.IsDefined(Term)) { writer.WritePropertyName("term"u8); @@ -47,6 +102,11 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("appliedScopeType"u8); writer.WriteStringValue(AppliedScopeType.Value.ToString()); } + if (options.Format != "W" && Optional.IsDefined(UserFriendlyAppliedScopeType)) + { + writer.WritePropertyName("userFriendlyAppliedScopeType"u8); + writer.WriteStringValue(UserFriendlyAppliedScopeType); + } if (Optional.IsDefined(AppliedScopeProperties)) { writer.WritePropertyName("appliedScopeProperties"u8); @@ -57,16 +117,41 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("commitment"u8); writer.WriteObjectValue(Commitment); } + if (options.Format != "W" && Optional.IsDefined(EffectOn)) + { + writer.WritePropertyName("effectiveDateTime"u8); + writer.WriteStringValue(EffectOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ExpireOn)) + { + writer.WritePropertyName("expiryDateTime"u8); + writer.WriteStringValue(ExpireOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(PurchaseOn)) + { + writer.WritePropertyName("purchaseDateTime"u8); + writer.WriteStringValue(PurchaseOn.Value, "O"); + } if (Optional.IsDefined(BenefitStartOn)) { writer.WritePropertyName("benefitStartTime"u8); writer.WriteStringValue(BenefitStartOn.Value, "O"); } + if (options.Format != "W" && Optional.IsDefined(ExtendedStatusInfo)) + { + writer.WritePropertyName("extendedStatusInfo"u8); + writer.WriteObjectValue(ExtendedStatusInfo); + } if (Optional.IsDefined(IsRenewed)) { writer.WritePropertyName("renew"u8); writer.WriteBooleanValue(IsRenewed.Value); } + if (options.Format != "W" && Optional.IsDefined(Utilization)) + { + writer.WritePropertyName("utilization"u8); + writer.WriteObjectValue(Utilization); + } if (Optional.IsDefined(RenewSource)) { writer.WritePropertyName("renewSource"u8); @@ -83,11 +168,40 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteObjectValue(RenewProperties); } writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } - internal static BillingBenefitsSavingsPlanData DeserializeBillingBenefitsSavingsPlanData(JsonElement element) + BillingBenefitsSavingsPlanData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBillingBenefitsSavingsPlanData(document.RootElement, options); + } + + internal static BillingBenefitsSavingsPlanData DeserializeBillingBenefitsSavingsPlanData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -120,6 +234,8 @@ internal static BillingBenefitsSavingsPlanData DeserializeBillingBenefitsSavings Optional renewSource = default; Optional renewDestination = default; Optional renewProperties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("sku"u8)) @@ -346,8 +462,44 @@ internal static BillingBenefitsSavingsPlanData DeserializeBillingBenefitsSavings } continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new BillingBenefitsSavingsPlanData(id, name, type, systemData.Value, sku, displayName.Value, Optional.ToNullable(provisioningState), displayProvisioningState.Value, billingScopeId.Value, billingProfileId.Value, customerId.Value, billingAccountId.Value, Optional.ToNullable(term), Optional.ToNullable(billingPlan), Optional.ToNullable(appliedScopeType), userFriendlyAppliedScopeType.Value, appliedScopeProperties.Value, commitment.Value, Optional.ToNullable(effectiveDateTime), Optional.ToNullable(expiryDateTime), Optional.ToNullable(purchaseDateTime), Optional.ToNullable(benefitStartTime), extendedStatusInfo.Value, Optional.ToNullable(renew), utilization.Value, renewSource.Value, renewDestination.Value, renewProperties.Value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanData)} does not support '{options.Format}' format."); + } + } + + BillingBenefitsSavingsPlanData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBillingBenefitsSavingsPlanData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanData)} does not support '{options.Format}' format."); } - return new BillingBenefitsSavingsPlanData(id, name, type, systemData.Value, sku, displayName.Value, Optional.ToNullable(provisioningState), displayProvisioningState.Value, billingScopeId.Value, billingProfileId.Value, customerId.Value, billingAccountId.Value, Optional.ToNullable(term), Optional.ToNullable(billingPlan), Optional.ToNullable(appliedScopeType), userFriendlyAppliedScopeType.Value, appliedScopeProperties.Value, commitment.Value, Optional.ToNullable(effectiveDateTime), Optional.ToNullable(expiryDateTime), Optional.ToNullable(purchaseDateTime), Optional.ToNullable(benefitStartTime), extendedStatusInfo.Value, Optional.ToNullable(renew), utilization.Value, renewSource.Value, renewDestination.Value, renewProperties.Value); } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanOrderAliasData.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanOrderAliasData.Serialization.cs index baa4daac15359..a7be2c34b69b8 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanOrderAliasData.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanOrderAliasData.Serialization.cs @@ -5,6 +5,9 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.BillingBenefits.Models; @@ -12,10 +15,18 @@ namespace Azure.ResourceManager.BillingBenefits { - public partial class BillingBenefitsSavingsPlanOrderAliasData : IUtf8JsonSerializable + public partial class BillingBenefitsSavingsPlanOrderAliasData : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanOrderAliasData)} does not support '{format}' format."); + } + writer.WriteStartObject(); writer.WritePropertyName("sku"u8); writer.WriteObjectValue(Sku); @@ -24,6 +35,26 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("kind"u8); writer.WriteStringValue(Kind); } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(DisplayName)) @@ -31,6 +62,16 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("displayName"u8); writer.WriteStringValue(DisplayName); } + if (options.Format != "W" && Optional.IsDefined(SavingsPlanOrderId)) + { + writer.WritePropertyName("savingsPlanOrderId"u8); + writer.WriteStringValue(SavingsPlanOrderId); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } if (Optional.IsDefined(BillingScopeId)) { writer.WritePropertyName("billingScopeId"u8); @@ -62,11 +103,40 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteObjectValue(Commitment); } writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } - internal static BillingBenefitsSavingsPlanOrderAliasData DeserializeBillingBenefitsSavingsPlanOrderAliasData(JsonElement element) + BillingBenefitsSavingsPlanOrderAliasData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanOrderAliasData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBillingBenefitsSavingsPlanOrderAliasData(document.RootElement, options); + } + + internal static BillingBenefitsSavingsPlanOrderAliasData DeserializeBillingBenefitsSavingsPlanOrderAliasData(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -86,6 +156,8 @@ internal static BillingBenefitsSavingsPlanOrderAliasData DeserializeBillingBenef Optional appliedScopeType = default; Optional appliedScopeProperties = default; Optional commitment = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("sku"u8)) @@ -211,8 +283,44 @@ internal static BillingBenefitsSavingsPlanOrderAliasData DeserializeBillingBenef } continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new BillingBenefitsSavingsPlanOrderAliasData(id, name, type, systemData.Value, sku, kind.Value, displayName.Value, savingsPlanOrderId.Value, Optional.ToNullable(provisioningState), billingScopeId.Value, Optional.ToNullable(term), Optional.ToNullable(billingPlan), Optional.ToNullable(appliedScopeType), appliedScopeProperties.Value, commitment.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new BillingBenefitsSavingsPlanOrderAliasData(id, name, type, systemData.Value, sku, kind.Value, displayName.Value, savingsPlanOrderId.Value, Optional.ToNullable(provisioningState), billingScopeId.Value, Optional.ToNullable(term), Optional.ToNullable(billingPlan), Optional.ToNullable(appliedScopeType), appliedScopeProperties.Value, commitment.Value, serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanOrderAliasData)} does not support '{options.Format}' format."); + } + } + + BillingBenefitsSavingsPlanOrderAliasData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBillingBenefitsSavingsPlanOrderAliasData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanOrderAliasData)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanOrderData.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanOrderData.Serialization.cs index cf6a9412db340..8280816eee5af 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanOrderData.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanOrderData.Serialization.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; @@ -14,13 +15,41 @@ namespace Azure.ResourceManager.BillingBenefits { - public partial class BillingBenefitsSavingsPlanOrderData : IUtf8JsonSerializable + public partial class BillingBenefitsSavingsPlanOrderData : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanOrderData)} does not support '{format}' format."); + } + writer.WriteStartObject(); writer.WritePropertyName("sku"u8); writer.WriteObjectValue(Sku); + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(DisplayName)) @@ -28,11 +57,31 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("displayName"u8); writer.WriteStringValue(DisplayName); } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } if (Optional.IsDefined(BillingScopeId)) { writer.WritePropertyName("billingScopeId"u8); writer.WriteStringValue(BillingScopeId); } + if (options.Format != "W" && Optional.IsDefined(BillingProfileId)) + { + writer.WritePropertyName("billingProfileId"u8); + writer.WriteStringValue(BillingProfileId); + } + if (options.Format != "W" && Optional.IsDefined(CustomerId)) + { + writer.WritePropertyName("customerId"u8); + writer.WriteStringValue(CustomerId); + } + if (options.Format != "W" && Optional.IsDefined(BillingAccountId)) + { + writer.WritePropertyName("billingAccountId"u8); + writer.WriteStringValue(BillingAccountId); + } if (Optional.IsDefined(Term)) { writer.WritePropertyName("term"u8); @@ -43,6 +92,11 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("billingPlan"u8); writer.WriteStringValue(BillingPlan.Value.ToString()); } + if (options.Format != "W" && Optional.IsDefined(ExpireOn)) + { + writer.WritePropertyName("expiryDateTime"u8); + writer.WriteStringValue(ExpireOn.Value, "O"); + } if (Optional.IsDefined(BenefitStartOn)) { writer.WritePropertyName("benefitStartTime"u8); @@ -63,12 +117,46 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } + if (options.Format != "W" && Optional.IsDefined(ExtendedStatusInfo)) + { + writer.WritePropertyName("extendedStatusInfo"u8); + writer.WriteObjectValue(ExtendedStatusInfo); + } writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } - internal static BillingBenefitsSavingsPlanOrderData DeserializeBillingBenefitsSavingsPlanOrderData(JsonElement element) + BillingBenefitsSavingsPlanOrderData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanOrderData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBillingBenefitsSavingsPlanOrderData(document.RootElement, options); + } + + internal static BillingBenefitsSavingsPlanOrderData DeserializeBillingBenefitsSavingsPlanOrderData(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -91,6 +179,8 @@ internal static BillingBenefitsSavingsPlanOrderData DeserializeBillingBenefitsSa Optional planInformation = default; Optional> savingsPlans = default; Optional extendedStatusInfo = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("sku"u8)) @@ -248,8 +338,44 @@ internal static BillingBenefitsSavingsPlanOrderData DeserializeBillingBenefitsSa } continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new BillingBenefitsSavingsPlanOrderData(id, name, type, systemData.Value, sku, displayName.Value, Optional.ToNullable(provisioningState), billingScopeId.Value, billingProfileId.Value, customerId.Value, billingAccountId.Value, Optional.ToNullable(term), Optional.ToNullable(billingPlan), Optional.ToNullable(expiryDateTime), Optional.ToNullable(benefitStartTime), planInformation.Value, Optional.ToList(savingsPlans), extendedStatusInfo.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new BillingBenefitsSavingsPlanOrderData(id, name, type, systemData.Value, sku, displayName.Value, Optional.ToNullable(provisioningState), billingScopeId.Value, billingProfileId.Value, customerId.Value, billingAccountId.Value, Optional.ToNullable(term), Optional.ToNullable(billingPlan), Optional.ToNullable(expiryDateTime), Optional.ToNullable(benefitStartTime), planInformation.Value, Optional.ToList(savingsPlans), extendedStatusInfo.Value, serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanOrderData)} does not support '{options.Format}' format."); + } + } + + BillingBenefitsSavingsPlanOrderData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBillingBenefitsSavingsPlanOrderData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanOrderData)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanPatch.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanPatch.Serialization.cs index b9a11487ec554..ed1b13244cccd 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanPatch.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanPatch.Serialization.cs @@ -5,22 +5,122 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - public partial class BillingBenefitsSavingsPlanPatch : IUtf8JsonSerializable + public partial class BillingBenefitsSavingsPlanPatch : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanPatch)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(Properties)) { writer.WritePropertyName("properties"u8); writer.WriteObjectValue(Properties); } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } + + BillingBenefitsSavingsPlanPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanPatch)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBillingBenefitsSavingsPlanPatch(document.RootElement, options); + } + + internal static BillingBenefitsSavingsPlanPatch DeserializeBillingBenefitsSavingsPlanPatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = BillingBenefitsSavingsPlanPatchProperties.DeserializeBillingBenefitsSavingsPlanPatchProperties(property.Value); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new BillingBenefitsSavingsPlanPatch(properties.Value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanPatch)} does not support '{options.Format}' format."); + } + } + + BillingBenefitsSavingsPlanPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBillingBenefitsSavingsPlanPatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanPatch)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanPatch.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanPatch.cs index 645bd5b31e4cd..7e39cc39d396b 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanPatch.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanPatch.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.BillingBenefits.Models { /// Savings plan patch request. public partial class BillingBenefitsSavingsPlanPatch { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . public BillingBenefitsSavingsPlanPatch() { @@ -17,9 +52,11 @@ public BillingBenefitsSavingsPlanPatch() /// Initializes a new instance of . /// Savings plan patch request. - internal BillingBenefitsSavingsPlanPatch(BillingBenefitsSavingsPlanPatchProperties properties) + /// Keeps track of any properties unknown to the library. + internal BillingBenefitsSavingsPlanPatch(BillingBenefitsSavingsPlanPatchProperties properties, IDictionary serializedAdditionalRawData) { Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Savings plan patch request. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanPatchProperties.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanPatchProperties.Serialization.cs index dd100c3ef8f9a..b2aea69558f55 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanPatchProperties.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanPatchProperties.Serialization.cs @@ -5,15 +5,26 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - public partial class BillingBenefitsSavingsPlanPatchProperties : IUtf8JsonSerializable + public partial class BillingBenefitsSavingsPlanPatchProperties : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanPatchProperties)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(DisplayName)) { @@ -40,7 +51,132 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("renewProperties"u8); writer.WriteObjectValue(RenewProperties); } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } + + BillingBenefitsSavingsPlanPatchProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanPatchProperties)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBillingBenefitsSavingsPlanPatchProperties(document.RootElement, options); + } + + internal static BillingBenefitsSavingsPlanPatchProperties DeserializeBillingBenefitsSavingsPlanPatchProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional displayName = default; + Optional appliedScopeType = default; + Optional appliedScopeProperties = default; + Optional renew = default; + Optional renewProperties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("appliedScopeType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + appliedScopeType = new BillingBenefitsAppliedScopeType(property.Value.GetString()); + continue; + } + if (property.NameEquals("appliedScopeProperties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + appliedScopeProperties = BillingBenefitsAppliedScopeProperties.DeserializeBillingBenefitsAppliedScopeProperties(property.Value); + continue; + } + if (property.NameEquals("renew"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + renew = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("renewProperties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + renewProperties = RenewProperties.DeserializeRenewProperties(property.Value); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new BillingBenefitsSavingsPlanPatchProperties(displayName.Value, Optional.ToNullable(appliedScopeType), appliedScopeProperties.Value, Optional.ToNullable(renew), renewProperties.Value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanPatchProperties)} does not support '{options.Format}' format."); + } + } + + BillingBenefitsSavingsPlanPatchProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBillingBenefitsSavingsPlanPatchProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanPatchProperties)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanPatchProperties.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanPatchProperties.cs index ae1668f0c5f70..40b85d503db79 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanPatchProperties.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanPatchProperties.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.BillingBenefits.Models { /// Savings plan patch request. public partial class BillingBenefitsSavingsPlanPatchProperties { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . public BillingBenefitsSavingsPlanPatchProperties() { @@ -21,13 +56,15 @@ public BillingBenefitsSavingsPlanPatchProperties() /// Properties specific to applied scope type. Not required if not applicable. /// Setting this to true will automatically purchase a new benefit on the expiration date time. /// - internal BillingBenefitsSavingsPlanPatchProperties(string displayName, BillingBenefitsAppliedScopeType? appliedScopeType, BillingBenefitsAppliedScopeProperties appliedScopeProperties, bool? isRenewed, RenewProperties renewProperties) + /// Keeps track of any properties unknown to the library. + internal BillingBenefitsSavingsPlanPatchProperties(string displayName, BillingBenefitsAppliedScopeType? appliedScopeType, BillingBenefitsAppliedScopeProperties appliedScopeProperties, bool? isRenewed, RenewProperties renewProperties, IDictionary serializedAdditionalRawData) { DisplayName = displayName; AppliedScopeType = appliedScopeType; AppliedScopeProperties = appliedScopeProperties; IsRenewed = isRenewed; RenewProperties = renewProperties; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Display name. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanUtilization.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanUtilization.Serialization.cs index 0e748b1fcdc2a..19593cb65a789 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanUtilization.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanUtilization.Serialization.cs @@ -5,22 +5,84 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - public partial class BillingBenefitsSavingsPlanUtilization + public partial class BillingBenefitsSavingsPlanUtilization : IUtf8JsonSerializable, IJsonModel { - internal static BillingBenefitsSavingsPlanUtilization DeserializeBillingBenefitsSavingsPlanUtilization(JsonElement element) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanUtilization)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Trend)) + { + writer.WritePropertyName("trend"u8); + writer.WriteStringValue(Trend); + } + if (Optional.IsCollectionDefined(Aggregates)) + { + writer.WritePropertyName("aggregates"u8); + writer.WriteStartArray(); + foreach (var item in Aggregates) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BillingBenefitsSavingsPlanUtilization IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanUtilization)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBillingBenefitsSavingsPlanUtilization(document.RootElement, options); + } + + internal static BillingBenefitsSavingsPlanUtilization DeserializeBillingBenefitsSavingsPlanUtilization(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional trend = default; Optional> aggregates = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("trend"u8)) @@ -42,8 +104,44 @@ internal static BillingBenefitsSavingsPlanUtilization DeserializeBillingBenefits aggregates = array; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new BillingBenefitsSavingsPlanUtilization(trend.Value, Optional.ToList(aggregates)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new BillingBenefitsSavingsPlanUtilization(trend.Value, Optional.ToList(aggregates), serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanUtilization)} does not support '{options.Format}' format."); + } + } + + BillingBenefitsSavingsPlanUtilization IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBillingBenefitsSavingsPlanUtilization(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanUtilization)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanUtilization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanUtilization.cs index efe2e8151dfed..09c86d170a5c8 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanUtilization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanUtilization.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.BillingBenefits.Models /// Savings plan utilization. public partial class BillingBenefitsSavingsPlanUtilization { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . internal BillingBenefitsSavingsPlanUtilization() { @@ -22,10 +55,12 @@ internal BillingBenefitsSavingsPlanUtilization() /// Initializes a new instance of . /// The number of days trend for a savings plan. /// The array of aggregates of a savings plan's utilization. - internal BillingBenefitsSavingsPlanUtilization(string trend, IReadOnlyList aggregates) + /// Keeps track of any properties unknown to the library. + internal BillingBenefitsSavingsPlanUtilization(string trend, IReadOnlyList aggregates, IDictionary serializedAdditionalRawData) { Trend = trend; Aggregates = aggregates; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The number of days trend for a savings plan. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanUtilizationAggregate.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanUtilizationAggregate.Serialization.cs index e6c64e223a030..85f93fa64deb2 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanUtilizationAggregate.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanUtilizationAggregate.Serialization.cs @@ -5,15 +5,81 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - public partial class BillingBenefitsSavingsPlanUtilizationAggregate + public partial class BillingBenefitsSavingsPlanUtilizationAggregate : IUtf8JsonSerializable, IJsonModel { - internal static BillingBenefitsSavingsPlanUtilizationAggregate DeserializeBillingBenefitsSavingsPlanUtilizationAggregate(JsonElement element) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanUtilizationAggregate)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Grain)) + { + writer.WritePropertyName("grain"u8); + writer.WriteNumberValue(Grain.Value); + } + if (options.Format != "W" && Optional.IsDefined(GrainUnit)) + { + writer.WritePropertyName("grainUnit"u8); + writer.WriteStringValue(GrainUnit); + } + if (options.Format != "W" && Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteNumberValue(Value.Value); + } + if (options.Format != "W" && Optional.IsDefined(ValueUnit)) + { + writer.WritePropertyName("valueUnit"u8); + writer.WriteStringValue(ValueUnit); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BillingBenefitsSavingsPlanUtilizationAggregate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanUtilizationAggregate)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBillingBenefitsSavingsPlanUtilizationAggregate(document.RootElement, options); + } + + internal static BillingBenefitsSavingsPlanUtilizationAggregate DeserializeBillingBenefitsSavingsPlanUtilizationAggregate(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -22,6 +88,8 @@ internal static BillingBenefitsSavingsPlanUtilizationAggregate DeserializeBillin Optional grainUnit = default; Optional value = default; Optional valueUnit = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("grain"u8)) @@ -52,8 +120,44 @@ internal static BillingBenefitsSavingsPlanUtilizationAggregate DeserializeBillin valueUnit = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new BillingBenefitsSavingsPlanUtilizationAggregate(Optional.ToNullable(grain), grainUnit.Value, Optional.ToNullable(value), valueUnit.Value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanUtilizationAggregate)} does not support '{options.Format}' format."); } - return new BillingBenefitsSavingsPlanUtilizationAggregate(Optional.ToNullable(grain), grainUnit.Value, Optional.ToNullable(value), valueUnit.Value); } + + BillingBenefitsSavingsPlanUtilizationAggregate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBillingBenefitsSavingsPlanUtilizationAggregate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BillingBenefitsSavingsPlanUtilizationAggregate)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanUtilizationAggregate.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanUtilizationAggregate.cs index 15c47cb9954ff..4a35e51f0f7f3 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanUtilizationAggregate.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSavingsPlanUtilizationAggregate.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.BillingBenefits.Models { /// The aggregate values of savings plan utilization. public partial class BillingBenefitsSavingsPlanUtilizationAggregate { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . internal BillingBenefitsSavingsPlanUtilizationAggregate() { @@ -20,12 +55,14 @@ internal BillingBenefitsSavingsPlanUtilizationAggregate() /// The grain unit of the aggregate. /// The aggregate value. /// The aggregate value unit. - internal BillingBenefitsSavingsPlanUtilizationAggregate(float? grain, string grainUnit, float? value, string valueUnit) + /// Keeps track of any properties unknown to the library. + internal BillingBenefitsSavingsPlanUtilizationAggregate(float? grain, string grainUnit, float? value, string valueUnit, IDictionary serializedAdditionalRawData) { Grain = grain; GrainUnit = grainUnit; Value = value; ValueUnit = valueUnit; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The grain of the aggregate. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSku.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSku.Serialization.cs index c7f0992325f63..fd782ed8094b4 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSku.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSku.Serialization.cs @@ -5,31 +5,73 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - public partial class BillingBenefitsSku : IUtf8JsonSerializable + public partial class BillingBenefitsSku : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsSku)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } - internal static BillingBenefitsSku DeserializeBillingBenefitsSku(JsonElement element) + BillingBenefitsSku IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingBenefitsSku)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBillingBenefitsSku(document.RootElement, options); + } + + internal static BillingBenefitsSku DeserializeBillingBenefitsSku(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -37,8 +79,44 @@ internal static BillingBenefitsSku DeserializeBillingBenefitsSku(JsonElement ele name = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new BillingBenefitsSku(name.Value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BillingBenefitsSku)} does not support '{options.Format}' format."); } - return new BillingBenefitsSku(name.Value); } + + BillingBenefitsSku IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBillingBenefitsSku(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BillingBenefitsSku)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSku.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSku.cs index 82c02de8341d5..e5ac90b8505f5 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSku.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingBenefitsSku.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.BillingBenefits.Models { /// The SKU to be applied for this resource. public partial class BillingBenefitsSku { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . public BillingBenefitsSku() { @@ -17,9 +52,11 @@ public BillingBenefitsSku() /// Initializes a new instance of . /// Name of the SKU to be applied. - internal BillingBenefitsSku(string name) + /// Keeps track of any properties unknown to the library. + internal BillingBenefitsSku(string name, IDictionary serializedAdditionalRawData) { Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Name of the SKU to be applied. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingPlanInformation.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingPlanInformation.Serialization.cs index 07f782d19def8..bb7c677b7fe69 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingPlanInformation.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingPlanInformation.Serialization.cs @@ -6,16 +6,25 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - public partial class BillingPlanInformation : IUtf8JsonSerializable + public partial class BillingPlanInformation : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingPlanInformation)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(PricingCurrencyTotal)) { @@ -42,11 +51,40 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } - internal static BillingPlanInformation DeserializeBillingPlanInformation(JsonElement element) + BillingPlanInformation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingPlanInformation)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBillingPlanInformation(document.RootElement, options); + } + + internal static BillingPlanInformation DeserializeBillingPlanInformation(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -55,6 +93,8 @@ internal static BillingPlanInformation DeserializeBillingPlanInformation(JsonEle Optional startDate = default; Optional nextPaymentDueDate = default; Optional> transactions = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("pricingCurrencyTotal"u8)) @@ -98,8 +138,44 @@ internal static BillingPlanInformation DeserializeBillingPlanInformation(JsonEle transactions = array; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new BillingPlanInformation(pricingCurrencyTotal.Value, Optional.ToNullable(startDate), Optional.ToNullable(nextPaymentDueDate), Optional.ToList(transactions)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new BillingPlanInformation(pricingCurrencyTotal.Value, Optional.ToNullable(startDate), Optional.ToNullable(nextPaymentDueDate), Optional.ToList(transactions), serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BillingPlanInformation)} does not support '{options.Format}' format."); + } + } + + BillingPlanInformation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBillingPlanInformation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BillingPlanInformation)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingPlanInformation.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingPlanInformation.cs index 97ed435a2d3d9..1a2d047d9116c 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingPlanInformation.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/BillingPlanInformation.cs @@ -14,6 +14,38 @@ namespace Azure.ResourceManager.BillingBenefits.Models /// Information describing the type of billing plan for this savings plan. public partial class BillingPlanInformation { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . public BillingPlanInformation() { @@ -25,12 +57,14 @@ public BillingPlanInformation() /// Date when the billing plan has started. /// For recurring billing plans, indicates the date when next payment will be processed. Null when total is paid off. /// - internal BillingPlanInformation(BillingBenefitsPrice pricingCurrencyTotal, DateTimeOffset? startOn, DateTimeOffset? nextPaymentDueOn, IList transactions) + /// Keeps track of any properties unknown to the library. + internal BillingPlanInformation(BillingBenefitsPrice pricingCurrencyTotal, DateTimeOffset? startOn, DateTimeOffset? nextPaymentDueOn, IList transactions, IDictionary serializedAdditionalRawData) { PricingCurrencyTotal = pricingCurrencyTotal; StartOn = startOn; NextPaymentDueOn = nextPaymentDueOn; Transactions = transactions; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Amount of money to be paid for the Order. Tax is not included. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/RenewProperties.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/RenewProperties.Serialization.cs index 097df0dac182d..3fe6588ec651a 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/RenewProperties.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/RenewProperties.Serialization.cs @@ -5,31 +5,73 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - internal partial class RenewProperties : IUtf8JsonSerializable + internal partial class RenewProperties : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RenewProperties)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(PurchaseProperties)) { writer.WritePropertyName("purchaseProperties"u8); writer.WriteObjectValue(PurchaseProperties); } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } - internal static RenewProperties DeserializeRenewProperties(JsonElement element) + RenewProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RenewProperties)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRenewProperties(document.RootElement, options); + } + + internal static RenewProperties DeserializeRenewProperties(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional purchaseProperties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("purchaseProperties"u8)) @@ -41,8 +83,44 @@ internal static RenewProperties DeserializeRenewProperties(JsonElement element) purchaseProperties = BillingBenefitsPurchaseContent.DeserializeBillingBenefitsPurchaseContent(property.Value); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new RenewProperties(purchaseProperties.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new RenewProperties(purchaseProperties.Value, serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RenewProperties)} does not support '{options.Format}' format."); + } + } + + RenewProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRenewProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RenewProperties)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/RenewProperties.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/RenewProperties.cs index a86b2010f37ef..72096e2056258 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/RenewProperties.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/RenewProperties.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.BillingBenefits.Models { /// The RenewProperties. internal partial class RenewProperties { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . public RenewProperties() { @@ -17,9 +52,11 @@ public RenewProperties() /// Initializes a new instance of . /// - internal RenewProperties(BillingBenefitsPurchaseContent purchaseProperties) + /// Keeps track of any properties unknown to the library. + internal RenewProperties(BillingBenefitsPurchaseContent purchaseProperties, IDictionary serializedAdditionalRawData) { PurchaseProperties = purchaseProperties; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Gets or sets the purchase properties. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/ReservationOrderAliasRequestPropertiesReservedResourceProperties.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/ReservationOrderAliasRequestPropertiesReservedResourceProperties.Serialization.cs index 0ab6fe0bd43eb..ed11f680e4c17 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/ReservationOrderAliasRequestPropertiesReservedResourceProperties.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/ReservationOrderAliasRequestPropertiesReservedResourceProperties.Serialization.cs @@ -5,31 +5,73 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - internal partial class ReservationOrderAliasRequestPropertiesReservedResourceProperties : IUtf8JsonSerializable + internal partial class ReservationOrderAliasRequestPropertiesReservedResourceProperties : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ReservationOrderAliasRequestPropertiesReservedResourceProperties)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(InstanceFlexibility)) { writer.WritePropertyName("instanceFlexibility"u8); writer.WriteStringValue(InstanceFlexibility.Value.ToString()); } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } - internal static ReservationOrderAliasRequestPropertiesReservedResourceProperties DeserializeReservationOrderAliasRequestPropertiesReservedResourceProperties(JsonElement element) + ReservationOrderAliasRequestPropertiesReservedResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ReservationOrderAliasRequestPropertiesReservedResourceProperties)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeReservationOrderAliasRequestPropertiesReservedResourceProperties(document.RootElement, options); + } + + internal static ReservationOrderAliasRequestPropertiesReservedResourceProperties DeserializeReservationOrderAliasRequestPropertiesReservedResourceProperties(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional instanceFlexibility = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("instanceFlexibility"u8)) @@ -41,8 +83,44 @@ internal static ReservationOrderAliasRequestPropertiesReservedResourceProperties instanceFlexibility = new BillingBenefitsInstanceFlexibility(property.Value.GetString()); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ReservationOrderAliasRequestPropertiesReservedResourceProperties(Optional.ToNullable(instanceFlexibility)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ReservationOrderAliasRequestPropertiesReservedResourceProperties(Optional.ToNullable(instanceFlexibility), serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ReservationOrderAliasRequestPropertiesReservedResourceProperties)} does not support '{options.Format}' format."); + } + } + + ReservationOrderAliasRequestPropertiesReservedResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeReservationOrderAliasRequestPropertiesReservedResourceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ReservationOrderAliasRequestPropertiesReservedResourceProperties)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/ReservationOrderAliasRequestPropertiesReservedResourceProperties.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/ReservationOrderAliasRequestPropertiesReservedResourceProperties.cs index 59d86466b4e3a..af3a72feb645e 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/ReservationOrderAliasRequestPropertiesReservedResourceProperties.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/ReservationOrderAliasRequestPropertiesReservedResourceProperties.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.BillingBenefits.Models { /// Properties specific to each reserved resource type. Not required if not applicable. internal partial class ReservationOrderAliasRequestPropertiesReservedResourceProperties { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . public ReservationOrderAliasRequestPropertiesReservedResourceProperties() { @@ -17,9 +52,11 @@ public ReservationOrderAliasRequestPropertiesReservedResourceProperties() /// Initializes a new instance of . /// Turning this on will apply the reservation discount to other VMs in the same VM size group. - internal ReservationOrderAliasRequestPropertiesReservedResourceProperties(BillingBenefitsInstanceFlexibility? instanceFlexibility) + /// Keeps track of any properties unknown to the library. + internal ReservationOrderAliasRequestPropertiesReservedResourceProperties(BillingBenefitsInstanceFlexibility? instanceFlexibility, IDictionary serializedAdditionalRawData) { InstanceFlexibility = instanceFlexibility; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Turning this on will apply the reservation discount to other VMs in the same VM size group. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/ReservationOrderAliasResponsePropertiesReservedResourceProperties.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/ReservationOrderAliasResponsePropertiesReservedResourceProperties.Serialization.cs index 2535ff00b4660..19b826c4375d0 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/ReservationOrderAliasResponsePropertiesReservedResourceProperties.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/ReservationOrderAliasResponsePropertiesReservedResourceProperties.Serialization.cs @@ -5,31 +5,73 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - internal partial class ReservationOrderAliasResponsePropertiesReservedResourceProperties : IUtf8JsonSerializable + internal partial class ReservationOrderAliasResponsePropertiesReservedResourceProperties : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ReservationOrderAliasResponsePropertiesReservedResourceProperties)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(InstanceFlexibility)) { writer.WritePropertyName("instanceFlexibility"u8); writer.WriteStringValue(InstanceFlexibility.Value.ToString()); } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } - internal static ReservationOrderAliasResponsePropertiesReservedResourceProperties DeserializeReservationOrderAliasResponsePropertiesReservedResourceProperties(JsonElement element) + ReservationOrderAliasResponsePropertiesReservedResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ReservationOrderAliasResponsePropertiesReservedResourceProperties)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeReservationOrderAliasResponsePropertiesReservedResourceProperties(document.RootElement, options); + } + + internal static ReservationOrderAliasResponsePropertiesReservedResourceProperties DeserializeReservationOrderAliasResponsePropertiesReservedResourceProperties(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional instanceFlexibility = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("instanceFlexibility"u8)) @@ -41,8 +83,44 @@ internal static ReservationOrderAliasResponsePropertiesReservedResourcePropertie instanceFlexibility = new BillingBenefitsInstanceFlexibility(property.Value.GetString()); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new ReservationOrderAliasResponsePropertiesReservedResourceProperties(Optional.ToNullable(instanceFlexibility)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ReservationOrderAliasResponsePropertiesReservedResourceProperties(Optional.ToNullable(instanceFlexibility), serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ReservationOrderAliasResponsePropertiesReservedResourceProperties)} does not support '{options.Format}' format."); + } + } + + ReservationOrderAliasResponsePropertiesReservedResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeReservationOrderAliasResponsePropertiesReservedResourceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ReservationOrderAliasResponsePropertiesReservedResourceProperties)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/ReservationOrderAliasResponsePropertiesReservedResourceProperties.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/ReservationOrderAliasResponsePropertiesReservedResourceProperties.cs index 517359df2515e..e6433363c7784 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/ReservationOrderAliasResponsePropertiesReservedResourceProperties.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/ReservationOrderAliasResponsePropertiesReservedResourceProperties.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.BillingBenefits.Models { /// Properties specific to each reserved resource type. Not required if not applicable. internal partial class ReservationOrderAliasResponsePropertiesReservedResourceProperties { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . public ReservationOrderAliasResponsePropertiesReservedResourceProperties() { @@ -17,9 +52,11 @@ public ReservationOrderAliasResponsePropertiesReservedResourceProperties() /// Initializes a new instance of . /// Turning this on will apply the reservation discount to other VMs in the same VM size group. - internal ReservationOrderAliasResponsePropertiesReservedResourceProperties(BillingBenefitsInstanceFlexibility? instanceFlexibility) + /// Keeps track of any properties unknown to the library. + internal ReservationOrderAliasResponsePropertiesReservedResourceProperties(BillingBenefitsInstanceFlexibility? instanceFlexibility, IDictionary serializedAdditionalRawData) { InstanceFlexibility = instanceFlexibility; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Turning this on will apply the reservation discount to other VMs in the same VM size group. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanModelList.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanModelList.Serialization.cs index 9a328760323fa..411fcc8cae750 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanModelList.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanModelList.Serialization.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; @@ -12,16 +14,76 @@ namespace Azure.ResourceManager.BillingBenefits.Models { - internal partial class SavingsPlanModelList + internal partial class SavingsPlanModelList : IUtf8JsonSerializable, IJsonModel { - internal static SavingsPlanModelList DeserializeSavingsPlanModelList(JsonElement element) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanModelList)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SavingsPlanModelList IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanModelList)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSavingsPlanModelList(document.RootElement, options); + } + + internal static SavingsPlanModelList DeserializeSavingsPlanModelList(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional> value = default; Optional nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value"u8)) @@ -43,8 +105,44 @@ internal static SavingsPlanModelList DeserializeSavingsPlanModelList(JsonElement nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new SavingsPlanModelList(Optional.ToList(value), nextLink.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new SavingsPlanModelList(Optional.ToList(value), nextLink.Value, serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SavingsPlanModelList)} does not support '{options.Format}' format."); + } + } + + SavingsPlanModelList IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSavingsPlanModelList(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SavingsPlanModelList)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanModelList.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanModelList.cs index 1cc2ee731406a..41f80cae139ef 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanModelList.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanModelList.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.BillingBenefits; @@ -14,6 +15,38 @@ namespace Azure.ResourceManager.BillingBenefits.Models /// The SavingsPlanModelList. internal partial class SavingsPlanModelList { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . internal SavingsPlanModelList() { @@ -23,10 +56,12 @@ internal SavingsPlanModelList() /// Initializes a new instance of . /// /// Url to get the next page. - internal SavingsPlanModelList(IReadOnlyList value, string nextLink) + /// Keeps track of any properties unknown to the library. + internal SavingsPlanModelList(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Gets the value. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanModelListResult.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanModelListResult.Serialization.cs index 186e511dc2416..104c0244c0138 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanModelListResult.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanModelListResult.Serialization.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; @@ -12,10 +14,78 @@ namespace Azure.ResourceManager.BillingBenefits.Models { - internal partial class SavingsPlanModelListResult + internal partial class SavingsPlanModelListResult : IUtf8JsonSerializable, IJsonModel { - internal static SavingsPlanModelListResult DeserializeSavingsPlanModelListResult(JsonElement element) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanModelListResult)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (options.Format != "W" && Optional.IsCollectionDefined(AdditionalProperties)) + { + writer.WritePropertyName("additionalProperties"u8); + writer.WriteStartArray(); + foreach (var item in AdditionalProperties) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SavingsPlanModelListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanModelListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSavingsPlanModelListResult(document.RootElement, options); + } + + internal static SavingsPlanModelListResult DeserializeSavingsPlanModelListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -23,6 +93,8 @@ internal static SavingsPlanModelListResult DeserializeSavingsPlanModelListResult Optional> value = default; Optional nextLink = default; Optional> additionalProperties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value"u8)) @@ -58,8 +130,44 @@ internal static SavingsPlanModelListResult DeserializeSavingsPlanModelListResult additionalProperties = array; continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new SavingsPlanModelListResult(Optional.ToList(value), nextLink.Value, Optional.ToList(additionalProperties)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new SavingsPlanModelListResult(Optional.ToList(value), nextLink.Value, Optional.ToList(additionalProperties), serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SavingsPlanModelListResult)} does not support '{options.Format}' format."); + } + } + + SavingsPlanModelListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSavingsPlanModelListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SavingsPlanModelListResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanModelListResult.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanModelListResult.cs index 83b935c2cf4b8..c403b861db21f 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanModelListResult.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanModelListResult.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.BillingBenefits; @@ -14,6 +15,38 @@ namespace Azure.ResourceManager.BillingBenefits.Models /// The SavingsPlanModelListResult. internal partial class SavingsPlanModelListResult { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . internal SavingsPlanModelListResult() { @@ -25,11 +58,13 @@ internal SavingsPlanModelListResult() /// The list of savings plans. /// Url to get the next page. /// The roll out count summary of the savings plans. - internal SavingsPlanModelListResult(IReadOnlyList value, string nextLink, IReadOnlyList additionalProperties) + /// Keeps track of any properties unknown to the library. + internal SavingsPlanModelListResult(IReadOnlyList value, string nextLink, IReadOnlyList additionalProperties, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; AdditionalProperties = additionalProperties; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The list of savings plans. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanOrderModelList.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanOrderModelList.Serialization.cs index 7c7cc818a8cb6..0666fdffb7610 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanOrderModelList.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanOrderModelList.Serialization.cs @@ -5,6 +5,8 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; @@ -12,16 +14,76 @@ namespace Azure.ResourceManager.BillingBenefits.Models { - internal partial class SavingsPlanOrderModelList + internal partial class SavingsPlanOrderModelList : IUtf8JsonSerializable, IJsonModel { - internal static SavingsPlanOrderModelList DeserializeSavingsPlanOrderModelList(JsonElement element) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanOrderModelList)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SavingsPlanOrderModelList IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanOrderModelList)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSavingsPlanOrderModelList(document.RootElement, options); + } + + internal static SavingsPlanOrderModelList DeserializeSavingsPlanOrderModelList(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional> value = default; Optional nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value"u8)) @@ -43,8 +105,44 @@ internal static SavingsPlanOrderModelList DeserializeSavingsPlanOrderModelList(J nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new SavingsPlanOrderModelList(Optional.ToList(value), nextLink.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new SavingsPlanOrderModelList(Optional.ToList(value), nextLink.Value, serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SavingsPlanOrderModelList)} does not support '{options.Format}' format."); + } + } + + SavingsPlanOrderModelList IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSavingsPlanOrderModelList(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SavingsPlanOrderModelList)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanOrderModelList.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanOrderModelList.cs index df0bb46371179..140a883a4ac19 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanOrderModelList.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanOrderModelList.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.BillingBenefits; @@ -14,6 +15,38 @@ namespace Azure.ResourceManager.BillingBenefits.Models /// The SavingsPlanOrderModelList. internal partial class SavingsPlanOrderModelList { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . internal SavingsPlanOrderModelList() { @@ -23,10 +56,12 @@ internal SavingsPlanOrderModelList() /// Initializes a new instance of . /// /// Url to get the next page. - internal SavingsPlanOrderModelList(IReadOnlyList value, string nextLink) + /// Keeps track of any properties unknown to the library. + internal SavingsPlanOrderModelList(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) { Value = value; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Gets the value. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanOrderPaymentDetail.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanOrderPaymentDetail.Serialization.cs index 428f17a3eba71..d60d542b11a90 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanOrderPaymentDetail.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanOrderPaymentDetail.Serialization.cs @@ -6,15 +6,25 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - public partial class SavingsPlanOrderPaymentDetail : IUtf8JsonSerializable + public partial class SavingsPlanOrderPaymentDetail : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanOrderPaymentDetail)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsDefined(DueOn)) { @@ -41,16 +51,50 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("status"u8); writer.WriteStringValue(Status.Value.ToString()); } + if (options.Format != "W" && Optional.IsDefined(ExtendedStatusInfo)) + { + writer.WritePropertyName("extendedStatusInfo"u8); + writer.WriteObjectValue(ExtendedStatusInfo); + } if (Optional.IsDefined(BillingAccount)) { writer.WritePropertyName("billingAccount"u8); writer.WriteStringValue(BillingAccount); } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } - internal static SavingsPlanOrderPaymentDetail DeserializeSavingsPlanOrderPaymentDetail(JsonElement element) + SavingsPlanOrderPaymentDetail IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanOrderPaymentDetail)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSavingsPlanOrderPaymentDetail(document.RootElement, options); + } + + internal static SavingsPlanOrderPaymentDetail DeserializeSavingsPlanOrderPaymentDetail(JsonElement element, ModelReaderWriterOptions options = null) { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -62,6 +106,8 @@ internal static SavingsPlanOrderPaymentDetail DeserializeSavingsPlanOrderPayment Optional status = default; Optional extendedStatusInfo = default; Optional billingAccount = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("dueDate"u8)) @@ -123,8 +169,44 @@ internal static SavingsPlanOrderPaymentDetail DeserializeSavingsPlanOrderPayment billingAccount = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new SavingsPlanOrderPaymentDetail(Optional.ToNullable(dueDate), Optional.ToNullable(paymentDate), pricingCurrencyTotal.Value, billingCurrencyTotal.Value, Optional.ToNullable(status), extendedStatusInfo.Value, billingAccount.Value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SavingsPlanOrderPaymentDetail)} does not support '{options.Format}' format."); } - return new SavingsPlanOrderPaymentDetail(Optional.ToNullable(dueDate), Optional.ToNullable(paymentDate), pricingCurrencyTotal.Value, billingCurrencyTotal.Value, Optional.ToNullable(status), extendedStatusInfo.Value, billingAccount.Value); } + + SavingsPlanOrderPaymentDetail IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSavingsPlanOrderPaymentDetail(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SavingsPlanOrderPaymentDetail)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanOrderPaymentDetail.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanOrderPaymentDetail.cs index 099c71a6cd4e9..ee085366e5751 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanOrderPaymentDetail.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanOrderPaymentDetail.cs @@ -6,12 +6,45 @@ #nullable disable using System; +using System.Collections.Generic; namespace Azure.ResourceManager.BillingBenefits.Models { /// Information about payment related to a savings plan order. public partial class SavingsPlanOrderPaymentDetail { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . public SavingsPlanOrderPaymentDetail() { @@ -25,7 +58,8 @@ public SavingsPlanOrderPaymentDetail() /// Describes whether the payment is completed, failed, cancelled or scheduled in the future. /// /// Billing account. - internal SavingsPlanOrderPaymentDetail(DateTimeOffset? dueOn, DateTimeOffset? payOn, BillingBenefitsPrice pricingCurrencyTotal, BillingBenefitsPrice billingCurrencyTotal, BillingBenefitsPaymentStatus? status, BillingBenefitsExtendedStatusInfo extendedStatusInfo, string billingAccount) + /// Keeps track of any properties unknown to the library. + internal SavingsPlanOrderPaymentDetail(DateTimeOffset? dueOn, DateTimeOffset? payOn, BillingBenefitsPrice pricingCurrencyTotal, BillingBenefitsPrice billingCurrencyTotal, BillingBenefitsPaymentStatus? status, BillingBenefitsExtendedStatusInfo extendedStatusInfo, string billingAccount, IDictionary serializedAdditionalRawData) { DueOn = dueOn; PayOn = payOn; @@ -34,6 +68,7 @@ internal SavingsPlanOrderPaymentDetail(DateTimeOffset? dueOn, DateTimeOffset? pa Status = status; ExtendedStatusInfo = extendedStatusInfo; BillingAccount = billingAccount; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Date when the payment needs to be done. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanPurchaseValidateContent.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanPurchaseValidateContent.Serialization.cs index 215bf3d37b2f1..bd1a70d3b0f1a 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanPurchaseValidateContent.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanPurchaseValidateContent.Serialization.cs @@ -5,15 +5,27 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.BillingBenefits; namespace Azure.ResourceManager.BillingBenefits.Models { - public partial class SavingsPlanPurchaseValidateContent : IUtf8JsonSerializable + public partial class SavingsPlanPurchaseValidateContent : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanPurchaseValidateContent)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsCollectionDefined(Benefits)) { @@ -25,7 +37,101 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } + + SavingsPlanPurchaseValidateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanPurchaseValidateContent)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSavingsPlanPurchaseValidateContent(document.RootElement, options); + } + + internal static SavingsPlanPurchaseValidateContent DeserializeSavingsPlanPurchaseValidateContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> benefits = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("benefits"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(BillingBenefitsSavingsPlanOrderAliasData.DeserializeBillingBenefitsSavingsPlanOrderAliasData(item)); + } + benefits = array; + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new SavingsPlanPurchaseValidateContent(Optional.ToList(benefits), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SavingsPlanPurchaseValidateContent)} does not support '{options.Format}' format."); + } + } + + SavingsPlanPurchaseValidateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSavingsPlanPurchaseValidateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SavingsPlanPurchaseValidateContent)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanPurchaseValidateContent.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanPurchaseValidateContent.cs index dd8e3717687a3..dad80da6b0fd7 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanPurchaseValidateContent.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanPurchaseValidateContent.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.BillingBenefits; @@ -14,6 +15,38 @@ namespace Azure.ResourceManager.BillingBenefits.Models /// The SavingsPlanPurchaseValidateContent. public partial class SavingsPlanPurchaseValidateContent { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . public SavingsPlanPurchaseValidateContent() { @@ -22,9 +55,11 @@ public SavingsPlanPurchaseValidateContent() /// Initializes a new instance of . /// - internal SavingsPlanPurchaseValidateContent(IList benefits) + /// Keeps track of any properties unknown to the library. + internal SavingsPlanPurchaseValidateContent(IList benefits, IDictionary serializedAdditionalRawData) { Benefits = benefits; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Gets the benefits. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanSummary.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanSummary.Serialization.cs index cf418479409c7..bd8d24b3a0d5b 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanSummary.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanSummary.Serialization.cs @@ -5,21 +5,79 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - internal partial class SavingsPlanSummary + internal partial class SavingsPlanSummary : IUtf8JsonSerializable, IJsonModel { - internal static SavingsPlanSummary DeserializeSavingsPlanSummary(JsonElement element) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanSummary)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteObjectValue(Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SavingsPlanSummary IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanSummary)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSavingsPlanSummary(document.RootElement, options); + } + + internal static SavingsPlanSummary DeserializeSavingsPlanSummary(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional name = default; Optional value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name"u8)) @@ -36,8 +94,44 @@ internal static SavingsPlanSummary DeserializeSavingsPlanSummary(JsonElement ele value = SavingsPlanSummaryCount.DeserializeSavingsPlanSummaryCount(property.Value); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new SavingsPlanSummary(name.Value, value.Value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SavingsPlanSummary)} does not support '{options.Format}' format."); + } + } + + SavingsPlanSummary IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSavingsPlanSummary(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SavingsPlanSummary)} does not support '{options.Format}' format."); } - return new SavingsPlanSummary(name.Value, value.Value); } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanSummary.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanSummary.cs index f10f82603c3db..07092212d020d 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanSummary.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanSummary.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.BillingBenefits.Models { /// Savings plans list summary. internal partial class SavingsPlanSummary { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . internal SavingsPlanSummary() { @@ -18,10 +53,12 @@ internal SavingsPlanSummary() /// Initializes a new instance of . /// This property has value 'summary'. /// The roll up count summary of savings plans in each state. - internal SavingsPlanSummary(string name, SavingsPlanSummaryCount value) + /// Keeps track of any properties unknown to the library. + internal SavingsPlanSummary(string name, SavingsPlanSummaryCount value, IDictionary serializedAdditionalRawData) { Name = name; Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// This property has value 'summary'. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanSummaryCount.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanSummaryCount.Serialization.cs index 687fae62fdaa7..bad0e5d52cbe4 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanSummaryCount.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanSummaryCount.Serialization.cs @@ -5,15 +5,106 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - internal partial class SavingsPlanSummaryCount + internal partial class SavingsPlanSummaryCount : IUtf8JsonSerializable, IJsonModel { - internal static SavingsPlanSummaryCount DeserializeSavingsPlanSummaryCount(JsonElement element) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanSummaryCount)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(SucceededCount)) + { + writer.WritePropertyName("succeededCount"u8); + writer.WriteNumberValue(SucceededCount.Value); + } + if (options.Format != "W" && Optional.IsDefined(FailedCount)) + { + writer.WritePropertyName("failedCount"u8); + writer.WriteNumberValue(FailedCount.Value); + } + if (options.Format != "W" && Optional.IsDefined(ExpiringCount)) + { + writer.WritePropertyName("expiringCount"u8); + writer.WriteNumberValue(ExpiringCount.Value); + } + if (options.Format != "W" && Optional.IsDefined(ExpiredCount)) + { + writer.WritePropertyName("expiredCount"u8); + writer.WriteNumberValue(ExpiredCount.Value); + } + if (options.Format != "W" && Optional.IsDefined(PendingCount)) + { + writer.WritePropertyName("pendingCount"u8); + writer.WriteNumberValue(PendingCount.Value); + } + if (options.Format != "W" && Optional.IsDefined(CancelledCount)) + { + writer.WritePropertyName("cancelledCount"u8); + writer.WriteNumberValue(CancelledCount.Value); + } + if (options.Format != "W" && Optional.IsDefined(ProcessingCount)) + { + writer.WritePropertyName("processingCount"u8); + writer.WriteNumberValue(ProcessingCount.Value); + } + if (options.Format != "W" && Optional.IsDefined(NoBenefitCount)) + { + writer.WritePropertyName("noBenefitCount"u8); + writer.WriteNumberValue(NoBenefitCount.Value); + } + if (options.Format != "W" && Optional.IsDefined(WarningCount)) + { + writer.WritePropertyName("warningCount"u8); + writer.WriteNumberValue(WarningCount.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SavingsPlanSummaryCount IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanSummaryCount)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSavingsPlanSummaryCount(document.RootElement, options); + } + + internal static SavingsPlanSummaryCount DeserializeSavingsPlanSummaryCount(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -27,6 +118,8 @@ internal static SavingsPlanSummaryCount DeserializeSavingsPlanSummaryCount(JsonE Optional processingCount = default; Optional noBenefitCount = default; Optional warningCount = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("succeededCount"u8)) @@ -110,8 +203,44 @@ internal static SavingsPlanSummaryCount DeserializeSavingsPlanSummaryCount(JsonE warningCount = property.Value.GetSingle(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new SavingsPlanSummaryCount(Optional.ToNullable(succeededCount), Optional.ToNullable(failedCount), Optional.ToNullable(expiringCount), Optional.ToNullable(expiredCount), Optional.ToNullable(pendingCount), Optional.ToNullable(cancelledCount), Optional.ToNullable(processingCount), Optional.ToNullable(noBenefitCount), Optional.ToNullable(warningCount)); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new SavingsPlanSummaryCount(Optional.ToNullable(succeededCount), Optional.ToNullable(failedCount), Optional.ToNullable(expiringCount), Optional.ToNullable(expiredCount), Optional.ToNullable(pendingCount), Optional.ToNullable(cancelledCount), Optional.ToNullable(processingCount), Optional.ToNullable(noBenefitCount), Optional.ToNullable(warningCount), serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SavingsPlanSummaryCount)} does not support '{options.Format}' format."); + } + } + + SavingsPlanSummaryCount IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSavingsPlanSummaryCount(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SavingsPlanSummaryCount)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanSummaryCount.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanSummaryCount.cs index d32eac674fa2c..ad16c7c19fd8f 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanSummaryCount.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanSummaryCount.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.BillingBenefits.Models { /// The roll up count summary of savings plans in each state. internal partial class SavingsPlanSummaryCount { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . internal SavingsPlanSummaryCount() { @@ -25,7 +60,8 @@ internal SavingsPlanSummaryCount() /// The number of savings plans in Processing state. /// The number of savings plans in No Benefit state. /// The number of savings plans in Warning state. - internal SavingsPlanSummaryCount(float? succeededCount, float? failedCount, float? expiringCount, float? expiredCount, float? pendingCount, float? cancelledCount, float? processingCount, float? noBenefitCount, float? warningCount) + /// Keeps track of any properties unknown to the library. + internal SavingsPlanSummaryCount(float? succeededCount, float? failedCount, float? expiringCount, float? expiredCount, float? pendingCount, float? cancelledCount, float? processingCount, float? noBenefitCount, float? warningCount, IDictionary serializedAdditionalRawData) { SucceededCount = succeededCount; FailedCount = failedCount; @@ -36,6 +72,7 @@ internal SavingsPlanSummaryCount(float? succeededCount, float? failedCount, floa ProcessingCount = processingCount; NoBenefitCount = noBenefitCount; WarningCount = warningCount; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// The number of savings plans in Succeeded state. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanUpdateValidateContent.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanUpdateValidateContent.Serialization.cs index 841815aac31c2..70c376f73bbe6 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanUpdateValidateContent.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanUpdateValidateContent.Serialization.cs @@ -5,15 +5,26 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - public partial class SavingsPlanUpdateValidateContent : IUtf8JsonSerializable + public partial class SavingsPlanUpdateValidateContent : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanUpdateValidateContent)} does not support '{format}' format."); + } + writer.WriteStartObject(); if (Optional.IsCollectionDefined(Benefits)) { @@ -25,7 +36,101 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) } writer.WriteEndArray(); } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } writer.WriteEndObject(); } + + SavingsPlanUpdateValidateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanUpdateValidateContent)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSavingsPlanUpdateValidateContent(document.RootElement, options); + } + + internal static SavingsPlanUpdateValidateContent DeserializeSavingsPlanUpdateValidateContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> benefits = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("benefits"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(BillingBenefitsSavingsPlanPatchProperties.DeserializeBillingBenefitsSavingsPlanPatchProperties(item)); + } + benefits = array; + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new SavingsPlanUpdateValidateContent(Optional.ToList(benefits), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SavingsPlanUpdateValidateContent)} does not support '{options.Format}' format."); + } + } + + SavingsPlanUpdateValidateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSavingsPlanUpdateValidateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SavingsPlanUpdateValidateContent)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanUpdateValidateContent.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanUpdateValidateContent.cs index ad84d6ca4812c..7ff75567b67ac 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanUpdateValidateContent.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanUpdateValidateContent.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.BillingBenefits.Models /// The SavingsPlanUpdateValidateContent. public partial class SavingsPlanUpdateValidateContent { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . public SavingsPlanUpdateValidateContent() { @@ -21,9 +54,11 @@ public SavingsPlanUpdateValidateContent() /// Initializes a new instance of . /// - internal SavingsPlanUpdateValidateContent(IList benefits) + /// Keeps track of any properties unknown to the library. + internal SavingsPlanUpdateValidateContent(IList benefits, IDictionary serializedAdditionalRawData) { Benefits = benefits; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Gets the benefits. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanValidateResponse.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanValidateResponse.Serialization.cs index 717a29668ae44..7643476c3fc31 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanValidateResponse.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanValidateResponse.Serialization.cs @@ -5,22 +5,84 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - internal partial class SavingsPlanValidateResponse + internal partial class SavingsPlanValidateResponse : IUtf8JsonSerializable, IJsonModel { - internal static SavingsPlanValidateResponse DeserializeSavingsPlanValidateResponse(JsonElement element) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanValidateResponse)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Benefits)) + { + writer.WritePropertyName("benefits"u8); + writer.WriteStartArray(); + foreach (var item in Benefits) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SavingsPlanValidateResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanValidateResponse)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSavingsPlanValidateResponse(document.RootElement, options); + } + + internal static SavingsPlanValidateResponse DeserializeSavingsPlanValidateResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; } Optional> benefits = default; Optional nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("benefits"u8)) @@ -42,8 +104,44 @@ internal static SavingsPlanValidateResponse DeserializeSavingsPlanValidateRespon nextLink = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new SavingsPlanValidateResponse(Optional.ToList(benefits), nextLink.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new SavingsPlanValidateResponse(Optional.ToList(benefits), nextLink.Value, serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SavingsPlanValidateResponse)} does not support '{options.Format}' format."); + } + } + + SavingsPlanValidateResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSavingsPlanValidateResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SavingsPlanValidateResponse)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanValidateResponse.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanValidateResponse.cs index db868f040b7a9..89ca9b0642334 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanValidateResponse.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanValidateResponse.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using Azure.Core; @@ -13,6 +14,38 @@ namespace Azure.ResourceManager.BillingBenefits.Models /// The SavingsPlanValidateResponse. internal partial class SavingsPlanValidateResponse { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . internal SavingsPlanValidateResponse() { @@ -22,10 +55,12 @@ internal SavingsPlanValidateResponse() /// Initializes a new instance of . /// /// Url to get the next page. - internal SavingsPlanValidateResponse(IReadOnlyList benefits, string nextLink) + /// Keeps track of any properties unknown to the library. + internal SavingsPlanValidateResponse(IReadOnlyList benefits, string nextLink, IDictionary serializedAdditionalRawData) { Benefits = benefits; NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Gets the benefits. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanValidateResult.Serialization.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanValidateResult.Serialization.cs index 0baa51b10c4eb..8e95c86fb75b5 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanValidateResult.Serialization.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanValidateResult.Serialization.cs @@ -5,15 +5,76 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; using Azure.Core; namespace Azure.ResourceManager.BillingBenefits.Models { - public partial class SavingsPlanValidateResult + public partial class SavingsPlanValidateResult : IUtf8JsonSerializable, IJsonModel { - internal static SavingsPlanValidateResult DeserializeSavingsPlanValidateResult(JsonElement element) + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanValidateResult)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(IsValid)) + { + writer.WritePropertyName("valid"u8); + writer.WriteBooleanValue(IsValid.Value); + } + if (Optional.IsDefined(ReasonCode)) + { + writer.WritePropertyName("reasonCode"u8); + writer.WriteStringValue(ReasonCode); + } + if (Optional.IsDefined(Reason)) + { + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(Reason); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SavingsPlanValidateResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsPlanValidateResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSavingsPlanValidateResult(document.RootElement, options); + } + + internal static SavingsPlanValidateResult DeserializeSavingsPlanValidateResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + if (element.ValueKind == JsonValueKind.Null) { return null; @@ -21,6 +82,8 @@ internal static SavingsPlanValidateResult DeserializeSavingsPlanValidateResult(J Optional valid = default; Optional reasonCode = default; Optional reason = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("valid"u8)) @@ -42,8 +105,44 @@ internal static SavingsPlanValidateResult DeserializeSavingsPlanValidateResult(J reason = property.Value.GetString(); continue; } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } } - return new SavingsPlanValidateResult(Optional.ToNullable(valid), reasonCode.Value, reason.Value); + serializedAdditionalRawData = additionalPropertiesDictionary; + return new SavingsPlanValidateResult(Optional.ToNullable(valid), reasonCode.Value, reason.Value, serializedAdditionalRawData); } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SavingsPlanValidateResult)} does not support '{options.Format}' format."); + } + } + + SavingsPlanValidateResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSavingsPlanValidateResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SavingsPlanValidateResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanValidateResult.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanValidateResult.cs index fbc28d1591352..5a7f1d4e4f456 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanValidateResult.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/Generated/Models/SavingsPlanValidateResult.cs @@ -5,11 +5,46 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace Azure.ResourceManager.BillingBenefits.Models { /// Benefit scope response property. public partial class SavingsPlanValidateResult { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . internal SavingsPlanValidateResult() { @@ -19,11 +54,13 @@ internal SavingsPlanValidateResult() /// Indicates if the provided input was valid. /// Failure reason code if the provided input was invalid. /// Failure reason if the provided input was invalid. - internal SavingsPlanValidateResult(bool? isValid, string reasonCode, string reason) + /// Keeps track of any properties unknown to the library. + internal SavingsPlanValidateResult(bool? isValid, string reasonCode, string reason, IDictionary serializedAdditionalRawData) { IsValid = isValid; ReasonCode = reasonCode; Reason = reason; + _serializedAdditionalRawData = serializedAdditionalRawData; } /// Indicates if the provided input was valid. diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/autorest.md b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/autorest.md index 78ead2943ea3e..061afedb17988 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/autorest.md +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/src/autorest.md @@ -15,6 +15,7 @@ clear-output-folder: true skip-csproj: true modelerfour: flatten-payloads: false +use-model-reader-writer: true list-exception: - /providers/Microsoft.BillingBenefits/savingsPlanOrderAliases/{savingsPlanOrderAliasName} diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/tests/Azure.ResourceManager.BillingBenefits.Tests.csproj b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/tests/Azure.ResourceManager.BillingBenefits.Tests.csproj index 1607b9147c2b4..86fe47884efc0 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/tests/Azure.ResourceManager.BillingBenefits.Tests.csproj +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/tests/Azure.ResourceManager.BillingBenefits.Tests.csproj @@ -2,4 +2,8 @@ + + + + diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/tests/ModelReaderWriterImplementationValidation.Exceptions.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/tests/ModelReaderWriterImplementationValidation.Exceptions.cs new file mode 100644 index 0000000000000..ba0530f9a3366 --- /dev/null +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/tests/ModelReaderWriterImplementationValidation.Exceptions.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Azure.ResourceManager.TestFramework +{ + public sealed partial class ModelReaderWriterImplementationValidation + { + public ModelReaderWriterImplementationValidation() + { + ExceptionList = new[] + { + "Azure.ResourceManager.BillingBenefits.Models.TenantResourceGetBillingBenefitsSavingsPlansOptions" + }; + } + } +} diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/tests/Scenario/SavingsPlansTests.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/tests/Scenario/SavingsPlansTests.cs index 81bc3da2864c3..860076d88d557 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/tests/Scenario/SavingsPlansTests.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/tests/Scenario/SavingsPlansTests.cs @@ -161,7 +161,7 @@ public async Task TestUpdateSavingsPlanWithRenewSetting() { PurchaseProperties = new BillingBenefitsPurchaseContent { - Sku = new BillingBenefitsSku("Compute_Savings_Plan"), + Sku = new BillingBenefitsSku("Compute_Savings_Plan", null), DisplayName = "TestRenewSP", BillingScopeId = new ResourceIdentifier("/subscriptions/eef82110-c91b-4395-9420-fcfcbefc5a47"), Term = new BillingBenefitsTerm("P1Y"), diff --git a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/tests/TestHelpers.cs b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/tests/TestHelpers.cs index 264e693cfa45f..0c1c70865145b 100644 --- a/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/tests/TestHelpers.cs +++ b/sdk/billingbenefits/Azure.ResourceManager.BillingBenefits/tests/TestHelpers.cs @@ -11,7 +11,7 @@ public static class TestHelpers { public static BillingBenefitsSavingsPlanOrderAliasData CreateSavingsPlanOrderAliasPurchaseRequest(BillingBenefitsAppliedScopeType scope) { - var request = new BillingBenefitsSavingsPlanOrderAliasData(new BillingBenefitsSku("Compute_Savings_Plan")) + var request = new BillingBenefitsSavingsPlanOrderAliasData(new BillingBenefitsSku("Compute_Savings_Plan", null)) { BillingScopeId = new ResourceIdentifier("/subscriptions/eef82110-c91b-4395-9420-fcfcbefc5a47"), Term = new BillingBenefitsTerm("P3Y"), @@ -47,7 +47,7 @@ public static BillingBenefitsSavingsPlanOrderAliasData CreateSavingsPlanOrderAli public static BillingBenefitsReservationOrderAliasCreateOrUpdateContent CreateReservationOrderAliasPurchaseRequest(BillingBenefitsAppliedScopeType scope) { - var request = new BillingBenefitsReservationOrderAliasCreateOrUpdateContent(new BillingBenefitsSku("Standard_B1s")) + var request = new BillingBenefitsReservationOrderAliasCreateOrUpdateContent(new BillingBenefitsSku("Standard_B1s", null)) { BillingScopeId = new ResourceIdentifier("/subscriptions/eef82110-c91b-4395-9420-fcfcbefc5a47"), Term = new BillingBenefitsTerm("P3Y"),