diff --git a/sdk/billing/Azure.ResourceManager.Billing/CHANGELOG.md b/sdk/billing/Azure.ResourceManager.Billing/CHANGELOG.md index 81c2c0d303b80..17057ffb1e54f 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/CHANGELOG.md +++ b/sdk/billing/Azure.ResourceManager.Billing/CHANGELOG.md @@ -10,6 +10,8 @@ ### Bugs Fixed +Added detection for empty string in the return value of createdByPrincipalTenantId in BillingRoleAssignmentProperties. Issue at https://github.com/Azure/azure-sdk-for-net/issues/47341. + ### Other Changes ## 1.2.0 (2024-09-13) diff --git a/sdk/billing/Azure.ResourceManager.Billing/src/Custom/Models/BillingRoleAssignmentProperties.Serialization.cs b/sdk/billing/Azure.ResourceManager.Billing/src/Custom/Models/BillingRoleAssignmentProperties.Serialization.cs new file mode 100644 index 0000000000000..bce26eb58b7fa --- /dev/null +++ b/sdk/billing/Azure.ResourceManager.Billing/src/Custom/Models/BillingRoleAssignmentProperties.Serialization.cs @@ -0,0 +1,296 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Billing.Models +{ + public partial class BillingRoleAssignmentProperties : IUtf8JsonSerializable, IJsonModel + { + internal static BillingRoleAssignmentProperties DeserializeBillingRoleAssignmentProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BillingProvisioningState? provisioningState = default; + DateTimeOffset? createdOn = default; + Guid? createdByPrincipalTenantId = default; + string createdByPrincipalId = default; + string createdByPrincipalPuid = default; + string createdByUserEmailAddress = default; + DateTimeOffset? modifiedOn = default; + string modifiedByPrincipalPuid = default; + string modifiedByUserEmailAddress = default; + string modifiedByPrincipalId = default; + Guid? modifiedByPrincipalTenantId = default; + string principalPuid = default; + string principalId = default; + Guid? principalTenantId = default; + ResourceIdentifier roleDefinitionId = default; + string scope = default; + string userAuthenticationType = default; + string userEmailAddress = default; + string principalTenantName = default; + string principalDisplayName = default; + BillingPrincipalType? principalType = default; + ResourceIdentifier billingRequestId = default; + ResourceIdentifier billingAccountId = default; + string billingAccountDisplayName = default; + ResourceIdentifier billingProfileId = default; + string billingProfileDisplayName = default; + ResourceIdentifier invoiceSectionId = default; + string invoiceSectionDisplayName = default; + ResourceIdentifier customerId = default; + string customerDisplayName = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new BillingProvisioningState(property.Value.GetString()); + continue; + } + if (property.NameEquals("createdOn"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdOn = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdByPrincipalTenantId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null || string.IsNullOrEmpty(property.Value.GetString())) + { + continue; + } + createdByPrincipalTenantId = property.Value.GetGuid(); + continue; + } + if (property.NameEquals("createdByPrincipalId"u8)) + { + createdByPrincipalId = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdByPrincipalPuid"u8)) + { + createdByPrincipalPuid = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdByUserEmailAddress"u8)) + { + createdByUserEmailAddress = property.Value.GetString(); + continue; + } + if (property.NameEquals("modifiedOn"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + modifiedOn = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("modifiedByPrincipalPuid"u8)) + { + modifiedByPrincipalPuid = property.Value.GetString(); + continue; + } + if (property.NameEquals("modifiedByUserEmailAddress"u8)) + { + modifiedByUserEmailAddress = property.Value.GetString(); + continue; + } + if (property.NameEquals("modifiedByPrincipalId"u8)) + { + modifiedByPrincipalId = property.Value.GetString(); + continue; + } + if (property.NameEquals("modifiedByPrincipalTenantId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + modifiedByPrincipalTenantId = property.Value.GetGuid(); + continue; + } + if (property.NameEquals("principalPuid"u8)) + { + principalPuid = property.Value.GetString(); + continue; + } + if (property.NameEquals("principalId"u8)) + { + principalId = property.Value.GetString(); + continue; + } + if (property.NameEquals("principalTenantId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + principalTenantId = property.Value.GetGuid(); + continue; + } + if (property.NameEquals("roleDefinitionId"u8)) + { + roleDefinitionId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("scope"u8)) + { + scope = property.Value.GetString(); + continue; + } + if (property.NameEquals("userAuthenticationType"u8)) + { + userAuthenticationType = property.Value.GetString(); + continue; + } + if (property.NameEquals("userEmailAddress"u8)) + { + userEmailAddress = property.Value.GetString(); + continue; + } + if (property.NameEquals("principalTenantName"u8)) + { + principalTenantName = property.Value.GetString(); + continue; + } + if (property.NameEquals("principalDisplayName"u8)) + { + principalDisplayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("principalType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + principalType = new BillingPrincipalType(property.Value.GetString()); + continue; + } + if (property.NameEquals("billingRequestId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + billingRequestId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("billingAccountId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + billingAccountId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("billingAccountDisplayName"u8)) + { + billingAccountDisplayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("billingProfileId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + billingProfileId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("billingProfileDisplayName"u8)) + { + billingProfileDisplayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("invoiceSectionId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + invoiceSectionId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("invoiceSectionDisplayName"u8)) + { + invoiceSectionDisplayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("customerId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + customerId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("customerDisplayName"u8)) + { + customerDisplayName = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BillingRoleAssignmentProperties( + provisioningState, + createdOn, + createdByPrincipalTenantId, + createdByPrincipalId, + createdByPrincipalPuid, + createdByUserEmailAddress, + modifiedOn, + modifiedByPrincipalPuid, + modifiedByUserEmailAddress, + modifiedByPrincipalId, + modifiedByPrincipalTenantId, + principalPuid, + principalId, + principalTenantId, + roleDefinitionId, + scope, + userAuthenticationType, + userEmailAddress, + principalTenantName, + principalDisplayName, + principalType, + billingRequestId, + billingAccountId, + billingAccountDisplayName, + billingProfileId, + billingProfileDisplayName, + invoiceSectionId, + invoiceSectionDisplayName, + customerId, + customerDisplayName, + serializedAdditionalRawData); + } + } +} diff --git a/sdk/billing/Azure.ResourceManager.Billing/src/Generated/Models/BillingRoleAssignmentProperties.Serialization.cs b/sdk/billing/Azure.ResourceManager.Billing/src/Generated/Models/BillingRoleAssignmentProperties.Serialization.cs index d8f5858e46f02..a9bfec283b33d 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/src/Generated/Models/BillingRoleAssignmentProperties.Serialization.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/src/Generated/Models/BillingRoleAssignmentProperties.Serialization.cs @@ -211,286 +211,6 @@ BillingRoleAssignmentProperties IJsonModel.Crea return DeserializeBillingRoleAssignmentProperties(document.RootElement, options); } - internal static BillingRoleAssignmentProperties DeserializeBillingRoleAssignmentProperties(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - BillingProvisioningState? provisioningState = default; - DateTimeOffset? createdOn = default; - Guid? createdByPrincipalTenantId = default; - string createdByPrincipalId = default; - string createdByPrincipalPuid = default; - string createdByUserEmailAddress = default; - DateTimeOffset? modifiedOn = default; - string modifiedByPrincipalPuid = default; - string modifiedByUserEmailAddress = default; - string modifiedByPrincipalId = default; - Guid? modifiedByPrincipalTenantId = default; - string principalPuid = default; - string principalId = default; - Guid? principalTenantId = default; - ResourceIdentifier roleDefinitionId = default; - string scope = default; - string userAuthenticationType = default; - string userEmailAddress = default; - string principalTenantName = default; - string principalDisplayName = default; - BillingPrincipalType? principalType = default; - ResourceIdentifier billingRequestId = default; - ResourceIdentifier billingAccountId = default; - string billingAccountDisplayName = default; - ResourceIdentifier billingProfileId = default; - string billingProfileDisplayName = default; - ResourceIdentifier invoiceSectionId = default; - string invoiceSectionDisplayName = default; - ResourceIdentifier customerId = default; - string customerDisplayName = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("provisioningState"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - provisioningState = new BillingProvisioningState(property.Value.GetString()); - continue; - } - if (property.NameEquals("createdOn"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - createdOn = property.Value.GetDateTimeOffset("O"); - continue; - } - if (property.NameEquals("createdByPrincipalTenantId"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - createdByPrincipalTenantId = property.Value.GetGuid(); - continue; - } - if (property.NameEquals("createdByPrincipalId"u8)) - { - createdByPrincipalId = property.Value.GetString(); - continue; - } - if (property.NameEquals("createdByPrincipalPuid"u8)) - { - createdByPrincipalPuid = property.Value.GetString(); - continue; - } - if (property.NameEquals("createdByUserEmailAddress"u8)) - { - createdByUserEmailAddress = property.Value.GetString(); - continue; - } - if (property.NameEquals("modifiedOn"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - modifiedOn = property.Value.GetDateTimeOffset("O"); - continue; - } - if (property.NameEquals("modifiedByPrincipalPuid"u8)) - { - modifiedByPrincipalPuid = property.Value.GetString(); - continue; - } - if (property.NameEquals("modifiedByUserEmailAddress"u8)) - { - modifiedByUserEmailAddress = property.Value.GetString(); - continue; - } - if (property.NameEquals("modifiedByPrincipalId"u8)) - { - modifiedByPrincipalId = property.Value.GetString(); - continue; - } - if (property.NameEquals("modifiedByPrincipalTenantId"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - modifiedByPrincipalTenantId = property.Value.GetGuid(); - continue; - } - if (property.NameEquals("principalPuid"u8)) - { - principalPuid = property.Value.GetString(); - continue; - } - if (property.NameEquals("principalId"u8)) - { - principalId = property.Value.GetString(); - continue; - } - if (property.NameEquals("principalTenantId"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - principalTenantId = property.Value.GetGuid(); - continue; - } - if (property.NameEquals("roleDefinitionId"u8)) - { - roleDefinitionId = new ResourceIdentifier(property.Value.GetString()); - continue; - } - if (property.NameEquals("scope"u8)) - { - scope = property.Value.GetString(); - continue; - } - if (property.NameEquals("userAuthenticationType"u8)) - { - userAuthenticationType = property.Value.GetString(); - continue; - } - if (property.NameEquals("userEmailAddress"u8)) - { - userEmailAddress = property.Value.GetString(); - continue; - } - if (property.NameEquals("principalTenantName"u8)) - { - principalTenantName = property.Value.GetString(); - continue; - } - if (property.NameEquals("principalDisplayName"u8)) - { - principalDisplayName = property.Value.GetString(); - continue; - } - if (property.NameEquals("principalType"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - principalType = new BillingPrincipalType(property.Value.GetString()); - continue; - } - if (property.NameEquals("billingRequestId"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - billingRequestId = new ResourceIdentifier(property.Value.GetString()); - continue; - } - if (property.NameEquals("billingAccountId"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - billingAccountId = new ResourceIdentifier(property.Value.GetString()); - continue; - } - if (property.NameEquals("billingAccountDisplayName"u8)) - { - billingAccountDisplayName = property.Value.GetString(); - continue; - } - if (property.NameEquals("billingProfileId"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - billingProfileId = new ResourceIdentifier(property.Value.GetString()); - continue; - } - if (property.NameEquals("billingProfileDisplayName"u8)) - { - billingProfileDisplayName = property.Value.GetString(); - continue; - } - if (property.NameEquals("invoiceSectionId"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - invoiceSectionId = new ResourceIdentifier(property.Value.GetString()); - continue; - } - if (property.NameEquals("invoiceSectionDisplayName"u8)) - { - invoiceSectionDisplayName = property.Value.GetString(); - continue; - } - if (property.NameEquals("customerId"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - customerId = new ResourceIdentifier(property.Value.GetString()); - continue; - } - if (property.NameEquals("customerDisplayName"u8)) - { - customerDisplayName = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new BillingRoleAssignmentProperties( - provisioningState, - createdOn, - createdByPrincipalTenantId, - createdByPrincipalId, - createdByPrincipalPuid, - createdByUserEmailAddress, - modifiedOn, - modifiedByPrincipalPuid, - modifiedByUserEmailAddress, - modifiedByPrincipalId, - modifiedByPrincipalTenantId, - principalPuid, - principalId, - principalTenantId, - roleDefinitionId, - scope, - userAuthenticationType, - userEmailAddress, - principalTenantName, - principalDisplayName, - principalType, - billingRequestId, - billingAccountId, - billingAccountDisplayName, - billingProfileId, - billingProfileDisplayName, - invoiceSectionId, - invoiceSectionDisplayName, - customerId, - customerDisplayName, - serializedAdditionalRawData); - } - private BinaryData SerializeBicep(ModelReaderWriterOptions options) { StringBuilder builder = new StringBuilder(); diff --git a/sdk/billing/Azure.ResourceManager.Billing/src/autorest.md b/sdk/billing/Azure.ResourceManager.Billing/src/autorest.md index c2f55df1b0d25..faf9ec9a87a4c 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/src/autorest.md +++ b/sdk/billing/Azure.ResourceManager.Billing/src/autorest.md @@ -23,7 +23,7 @@ modelerfour: use-model-reader-writer: true enable-bicep-serialization: true -#mgmt-debug: +# mgmt-debug: # show-serialized-names: true request-path-to-resource-name: